/* ============================================================
   River Monitoring System - Modern UI
   ============================================================ */

:root {
    --primary: #0d6efd;
    --primary-grad-start: #00a8e8;
    --primary-grad-end: #00c389;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e9f0;
    --danger: #ef4444;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(17, 24, 39, 0.06);
    --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);
}

html {
    font-size: 15px;
}

body {
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
}

a {
    text-decoration: none;
    color: var(--primary);
}

a:hover {
    color: #0a58ca;
}

/* ---------- Header ---------- */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(17, 24, 39, 0.04);
}

.header-bar a.home {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-bar a.home i {
    color: var(--primary);
}

.user-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-section .user-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.user-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-grad-start), var(--primary-grad-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
}

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text);
    border-radius: 8px;
}

.dropdown-item:hover {
    background: #f0f4ff;
    color: var(--primary);
}

/* ---------- Cards & grids ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.card-wrapper {
    width: 100%;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.6rem;
}

canvas {
    background: #fff;
    border-radius: 10px;
    width: 100% !important;
    height: 250px !important;
}

/* ---------- Number summary ---------- */
.number-summary {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.number-summary .title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.number-summary .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.15;
    word-break: break-word;
    overflow-wrap: anywhere;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.2rem;
}

.number-summary .unit {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ---------- Alarm toggle ---------- */
.alarm-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.9rem 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.alarm-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background: linear-gradient(90deg, var(--primary-grad-start), var(--primary-grad-end));
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ---------- Tables ---------- */
.table {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.table thead th {
    background: #1f2937;
    color: #fff;
    border: none;
    font-weight: 500;
    padding: 0.75rem 1rem;
}

.table tbody td {
    padding: 0.6rem 1rem;
    vertical-align: middle;
}

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 0.6rem 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-grad-start);
    box-shadow: 0 0 0 0.2rem rgba(0, 168, 232, 0.15);
}

.btn {
    border-radius: 10px;
    padding: 0.5rem 1.1rem;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary-grad-start), var(--primary-grad-end));
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(90deg, #0091cf, #00b27a);
    transform: translateY(-1px);
}

/* ---------- Status helpers ---------- */
.blinking {
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.text-danger {
    color: var(--danger) !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 810px) {
    .header-bar a.home {
        font-size: 1.1rem;
    }
    .user-section .user-label {
        display: none;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .card .row > .col-9 {
        display: none;
    }
    .card .col-3 {
        width: 100% !important;
        flex: 0 0 100% !important;
    }
    .number-summary .value {
        font-size: 1.5rem;
    }
}
