/* ============================================================
   Irrigation System — site.css
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:      #3498db;
    --blue-dark: #2980b9;
    --green:     #27ae60;
    --red:       #e74c3c;
    --amber:     #f39c12;
    --gray-50:   #f8f9fa;
    --gray-100:  #e9ecef;
    --gray-300:  #ced4da;
    --gray-600:  #6c757d;
    --gray-800:  #343a40;
    --white:     #ffffff;
    --radius:    8px;
    --shadow:    0 2px 8px rgba(0,0,0,.08);
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #eef2f3;
    color: var(--gray-800);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Navbar ---- */
.navbar {
    background: var(--gray-800);
    color: white;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.1rem;
    font-weight: 600;
}
.nav-icon { font-size: 1.4rem; }
.nav-links { display: flex; gap: .25rem; }
.nav-links a {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    padding: .4rem .9rem;
    border-radius: var(--radius);
    transition: background .15s;
    font-size: .95rem;
}
.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,.15);
    color: white;
}

/* ---- Main content ---- */
.main-content {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 1rem;
    font-size: .85rem;
    color: var(--gray-600);
    border-top: 1px solid var(--gray-100);
    background: white;
}

/* ---- Alerts ---- */
.alert {
    padding: .8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .95rem;
}
.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; }
.subtitle { color: var(--gray-600); font-size: .9rem; margin-top: .2rem; }

/* ---- Stat pill ---- */
.stat-pill {
    padding: .4rem 1rem;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 500;
}
.stat-active { background: #d4edda; color: #155724; }
.stat-idle   { background: var(--gray-100); color: var(--gray-600); }

/* ---- Nodes grid ---- */
.nodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.node-card {
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--gray-300);
    transition: transform .15s;
}
.node-card:hover    { transform: translateY(-2px); }
.node-card.online   { border-top-color: var(--green); }
.node-card.offline  { border-top-color: var(--red); opacity: .75; }
.node-card.open     { border-top-color: var(--blue); }

.node-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
}
.node-title { font-weight: 600; font-size: 1rem; }

/* ---- Badges ---- */
.badge {
    font-size: .7rem;
    padding: .25rem .6rem;
    border-radius: 12px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}
.badge-online  { background: var(--green); }
.badge-offline { background: var(--red); }
.badge-active  { background: var(--blue); }
.badge-pending { background: var(--amber); color: white; }
.badge-done    { background: var(--gray-600); }

/* ---- Valve status ---- */
.valve-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: .6rem;
}
.valve-open  { color: var(--blue); }
.valve-closed { color: var(--gray-600); }
.valve-icon { font-size: 1.2rem; }

.relay-row {
    display: flex;
    gap: .4rem;
    margin-bottom: .5rem;
}
.relay {
    flex: 1;
    text-align: center;
    padding: .2rem .4rem;
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 600;
}
.relay-on  { background: #d4edda; color: #155724; }
.relay-off { background: var(--gray-100); color: var(--gray-600); }

.last-seen {
    font-size: .8rem;
    color: var(--gray-600);
    margin-top: .4rem;
}
.muted { color: var(--gray-600); font-style: italic; }

/* ---- Section block ---- */
.section-block {
    background: white;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.section-block h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--gray-100);
}

/* ---- Table ---- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
.table th, .table td {
    padding: .65rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}
.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.table tbody tr:hover { background: var(--gray-50); }
.row-active { background: #e8f4fd !important; }
.row-disabled { opacity: .5; }
.table-sm td, .table-sm th { padding: .45rem .75rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-800);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover     { background: var(--gray-50); }
.btn-primary   { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger    { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover  { background: #c0392b; }
.btn-sm        { padding: .3rem .65rem; font-size: .82rem; }
.btn-xs        { padding: .2rem .55rem; font-size: .78rem; }

/* ---- Toggle button ---- */
.toggle-btn {
    padding: .25rem .7rem;
    border-radius: 12px;
    border: none;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.toggle-on  { background: #d4edda; color: #155724; }
.toggle-off { background: var(--gray-100); color: var(--gray-600); }

/* ---- Form card ---- */
.form-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    max-width: 560px;
}
.danger-card { border-top: 4px solid var(--red); }

.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: .35rem;
    font-size: .92rem;
}
.form-group-inline {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.form-group-inline label { margin-bottom: 0; }
.form-control {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .95rem;
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(52,152,219,.15);
}
.checkbox { width: 18px; height: 18px; cursor: pointer; }
.validation-error { color: var(--red); font-size: .82rem; display: block; margin-top: .25rem; }
.hint { color: var(--gray-600); font-size: .82rem; display: block; margin-top: .35rem; }

.input-with-unit {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.input-with-unit .form-control { flex: 1; }
.unit { font-size: .9rem; color: var(--gray-600); white-space: nowrap; }

/* ---- Days grid ---- */
.days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .6rem;
}
.day-chip {
    padding: .4rem .85rem;
    border: 1px solid var(--gray-300);
    border-radius: 20px;
    font-size: .85rem;
    cursor: pointer;
    user-select: none;
    transition: background .12s, border-color .12s;
}
.day-chip input[type="checkbox"] { display: none; }
.day-chip.checked {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
    font-weight: 600;
}
.day-shortcuts { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }

/* ---- Actions row ---- */
.actions-cell { white-space: nowrap; display: flex; gap: .4rem; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; align-items: center; }

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}
.empty-state p { margin-bottom: 1rem; font-size: 1.05rem; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .nodes-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .table { font-size: .82rem; }
    .table th, .table td { padding: .5rem .6rem; }
}
