/* ========== 基本設定 ========== */
:root {
    --primary-color: #1a73e8;
    --primary-light: #4285f4;
    --primary-dark: #0d47a1;
    --secondary-color: #00bcd4;
    --accent-color: #00e5ff;

    --danger-color: #e53935;
    --warning-color: #ff9800;
    --success-color: #4caf50;
    --info-color: #03a9f4;

    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-dark: #1a2332;
    --bg-card: #ffffff;

    --text-primary: #1a2332;
    --text-secondary: #5f6368;
    --text-light: #9aa0a6;
    --text-white: #ffffff;

    --border-color: #e0e4e8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #e3eaf2 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ========== コンテナ ========== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== ヘッダー ========== */
.header {
    background: linear-gradient(135deg, var(--bg-dark) 0%, #2d3a4d 100%);
    padding: 20px 32px;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-logo {
    height: 44px;
    width: 44px;
    object-fit: contain;
    border-radius: 50%;
}

.logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: 0.05em;
}

.title {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-white);
    padding-left: 24px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(76, 175, 80, 0.2);
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(76, 175, 80, 0.4);
}

.status-badge.error {
    background: rgba(229, 57, 53, 0.2);
    border-color: rgba(229, 57, 53, 0.4);
}

.status-badge.error .status-dot {
    background: var(--danger-color);
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--success-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

.status-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-white);
}

.datetime {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-white);
    font-variant-numeric: tabular-nums;
}

/* ========== メインコンテンツ ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ========== ダッシュボード ========== */
.dashboard {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 32px;
    align-items: center;
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.water-level-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.level-circle {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.level-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.level-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.level-unit {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.level-label {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* レベルカラー */
.level-circle.danger .level-number { color: var(--danger-color); }
.level-circle.warning .level-number { color: var(--warning-color); }
.level-circle.normal .level-number { color: var(--success-color); }
.level-circle.low .level-number { color: #8bc34a; }
.level-circle.very-low .level-number { color: var(--info-color); }

/* ステータスカード */
.status-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.status-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.status-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg {
    width: 28px;
    height: 28px;
}

.water-icon {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: var(--primary-color);
}

.area-icon {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: var(--success-color);
}

.camera-icon {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    color: var(--warning-color);
}

.time-icon {
    background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
    color: #9c27b0;
}

.card-content {
    flex: 1;
    min-width: 0;
}

.card-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.card-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 画像セクション ========== */
.image-section {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.image-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.image-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.image-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.image-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.image-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-xl);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.image-badge.live {
    background: var(--danger-color);
    color: white;
    animation: pulse 2s infinite;
}

.image-badge.ai {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.image-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #1a2332;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
}

.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-light);
}

.image-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.image-placeholder span {
    font-size: 0.875rem;
}

/* ========== 履歴グラフセクション ========== */
.history-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.history-container {
    display: flex;
    flex-direction: column;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #2d3a4d 100%);
    flex-wrap: wrap;
    gap: 16px;
}

.history-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
}

.period-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.period-btn {
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: var(--text-white);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.period-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.period-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.history-stats {
    display: flex;
    gap: 24px;
    padding: 16px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.chart-container {
    padding: 24px;
    height: 300px;
    background: var(--bg-card);
}

/* ========== ゲージセクション ========== */
.gauge-section {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
}

.gauge-container,
.tech-info {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.gauge-header,
.tech-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #2d3a4d 100%);
}

.gauge-header h3,
.tech-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-white);
}

.gauge-body {
    display: flex;
    padding: 32px;
    gap: 48px;
}

.vertical-gauge {
    display: flex;
    gap: 16px;
    flex: 1;
}

.gauge-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 0;
}

.gauge-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.gauge-label.high { color: var(--danger-color); }
.gauge-label.mid { color: var(--success-color); }
.gauge-label.low { color: var(--info-color); }

.gauge-bar {
    position: relative;
    width: 60px;
    height: 200px;
    background: linear-gradient(to bottom,
        rgba(229, 57, 53, 0.1) 0%,
        rgba(255, 152, 0, 0.1) 30%,
        rgba(76, 175, 80, 0.1) 60%,
        rgba(3, 169, 244, 0.1) 100%
    );
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.gauge-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(to top, var(--primary-color), var(--secondary-color));
    transition: height 0.5s ease, background 0.3s ease;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.gauge-marker {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
}

.gauge-marker::after {
    content: '';
    position: absolute;
    right: -8px;
    top: -4px;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 8px solid currentColor;
}

.high-marker { top: 10%; color: var(--danger-color); }
.mid-marker { top: 50%; color: var(--success-color); }
.low-marker { top: 80%; color: var(--info-color); }

.gauge-scale {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.75rem;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

.gauge-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-item.danger .legend-color { background: var(--danger-color); }
.legend-item.warning .legend-color { background: var(--warning-color); }
.legend-item.normal .legend-color { background: var(--success-color); }
.legend-item.low .legend-color { background: var(--info-color); }

.legend-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* 技術情報 */
.tech-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tech-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.tech-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tech-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== フッター ========== */
.footer {
    background: var(--bg-dark);
    padding: 20px 32px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-top: 24px;
}

.footer-content {
    text-align: center;
}

.footer-content p {
    color: var(--text-white);
    font-size: 0.875rem;
}

.footer-content .copyright {
    color: var(--text-light);
    font-size: 0.75rem;
    margin-top: 4px;
}

/* ========== レスポンシブ ========== */
@media (max-width: 1400px) {
    .gauge-section {
        grid-template-columns: 1fr;
    }

    .tech-info {
        display: none;
    }
}

@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .water-level-display {
        flex-direction: row;
        gap: 32px;
    }

    .status-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .image-container {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .logo-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .title {
        padding-left: 0;
        border-left: none;
        font-size: 1.25rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 12px;
    }

    .header {
        padding: 16px;
    }

    .dashboard {
        padding: 20px;
    }

    .status-cards {
        grid-template-columns: 1fr;
    }

    .water-level-display {
        flex-direction: column;
    }

    .level-circle {
        width: 140px;
        height: 140px;
    }

    .level-number {
        font-size: 2.5rem;
    }
}

/* ========== アニメーション ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard,
.image-section,
.history-section,
.gauge-section > * {
    animation: fadeIn 0.5s ease-out;
}

.image-section { animation-delay: 0.1s; }
.history-section { animation-delay: 0.15s; }
.gauge-section > *:nth-child(1) { animation-delay: 0.2s; }
.gauge-section > *:nth-child(2) { animation-delay: 0.3s; }

/* ========== スクロールバー ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
