@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&family=Raleway:wght@600;700&display=swap');

:root {
    --bg:         #f0f2f5;
    --surface:    #ffffff;
    --border:     #dde1e7;
    --text:       #333333;
    --muted:      #6c757d;
    --nav-bg:     #0e5077;
    --nav-hover:  #043d5f;
    --nav-active: #006687;
    --accent:     #0e5077;
    --accent-btn: #337ab7;
    --danger:     #c0392b;
    --success:    #4da24c;
    --warning:    #e67e22;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
}

/* ── TOPNAV ── */
.topnav {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--nav-bg);
    border-bottom: none;
    min-height: 50px;
    padding: 0 24px;
    font-family: 'Raleway', "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
}
.topnav .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
    margin-right: 24px;
    letter-spacing: .5px;
    white-space: nowrap;
}
.topnav nav {
    display: flex;
    gap: 0;
    flex: 1;
}
.topnav nav a {
    color: #fff;
    text-decoration: none;
    padding: 0 14px;
    line-height: 50px;
    display: block;
    opacity: .92;
    transition: background .15s, opacity .15s;
}
.topnav nav a:hover {
    background: var(--nav-hover);
    opacity: 1;
}
.topnav nav a.active {
    background: var(--nav-active);
    opacity: 1;
}
.user-info {
    color: rgba(255,255,255,.75);
    font-size: .85rem;
    white-space: nowrap;
}
.user-info a { color: #7ec8f0; text-decoration: none; }
.user-info a:hover { color: #fff; }

/* ── LAYOUT ── */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 24px; }

h1, h2, h3, h4 {
    font-family: 'Raleway', "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: var(--accent);
    margin-top: 0;
}
h1 { font-size: 1.75rem; margin-bottom: 1.2rem; }
h2 { font-size: 1.35rem; margin-bottom: .8rem; }
h3 { font-size: 1.1rem; margin-bottom: .5rem; color: #2c3e50; }

a { color: var(--accent-btn); }
a:hover { color: var(--nav-hover); }

/* ── LOGIN ── */
.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 36px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 2px 12px rgba(14,80,119,.1);
}
.login-box h1 {
    margin: 0 0 8px;
    text-align: center;
    font-size: 1.5rem;
    color: var(--nav-bg);
}
.login-box label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .9rem;
    color: var(--muted);
}

/* ── FORMS ── */
.login-box input,
.camera-form input,
.camera-form select,
.camera-form textarea,
.filters input,
.filters select,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 10px;
    border-radius: 5px;
    font-size: .9rem;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-btn);
    box-shadow: 0 0 0 3px rgba(51,122,183,.15);
}

/* ── BUTTONS ── */
button, .btn {
    background: var(--accent-btn);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: .9rem;
    font-family: inherit;
    transition: background .15s;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover { background: var(--nav-hover); color: #fff; }
button.btn-danger, .btn-danger { background: var(--danger); }
button.btn-danger:hover, .btn-danger:hover { background: #a93226; }
button.btn-sm, .btn-sm { padding: 4px 10px; font-size: .8rem; }

/* ── MESSAGES ── */
.error  { color: var(--danger); }
.flash  { color: var(--success); }
.alert {
    padding: 10px 14px;
    border-radius: 5px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert-success { background: #d4edda; color: #155724; border-color: #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border-color: #f5c6cb; }

/* ── CARDS ── */
.cards { display: flex; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--nav-bg);
    border-radius: 6px;
    padding: 20px 24px;
    flex: 1;
    min-width: 140px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-value { display: block; font-size: 2rem; font-weight: 700; color: var(--nav-bg); }
.card-label { color: var(--muted); font-size: .85rem; }

/* ── TABLES ── */
.table { width: 100%; border-collapse: collapse; margin: 12px 0; background: var(--surface); border-radius: 6px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { background: #f0f4f8; color: var(--muted); font-weight: 600; font-size: .85rem; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f7f9fb; }

/* ── GRID DE PANELES (ej. un chart por cámara) ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin: 12px 0 20px; }
.stats-grid .panel { margin-bottom: 0; }

/* ── BAR CHARTS (listas simples, sin dependencias JS) ── */
.bar-chart { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 20px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 56px; align-items: center; gap: 10px; font-size: .85rem; }
.bar-row .bar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef2f6; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { background: var(--nav-bg); height: 100%; border-radius: 4px; }
.bar-row .bar-value { text-align: right; font-weight: 600; }

/* ── BADGES ── */
.badge { padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-online  { background: rgba(77,162,76,.15);  color: #2d7a2c; }
.badge-offline, .badge-error { background: rgba(192,57,43,.12); color: #a93226; }
.badge-unknown { background: rgba(108,117,125,.12); color: var(--muted); }

/* ── ACTIONS ── */
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions button, .actions a { font-size: .82rem; }

/* ── FORMS EXTRAS ── */
.camera-form { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.camera-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; }

/* ── NAV DROPDOWN ── */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-toggle {
    color: #fff;
    text-decoration: none;
    padding: 0 14px;
    line-height: 50px;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: .92;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    user-select: none;
}
.nav-dropdown-toggle::after {
    content: '▾';
    font-size: .75rem;
}
.nav-dropdown:hover .nav-dropdown-toggle,
.nav-dropdown:focus-within .nav-dropdown-toggle {
    background: var(--nav-hover);
    opacity: 1;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--nav-bg);
    min-width: 190px;
    z-index: 200;
    border-top: 2px solid var(--nav-active);
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
    border-radius: 0 0 5px 5px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-menu a {
    display: block;
    color: rgba(255,255,255,.92);
    text-decoration: none;
    padding: 9px 16px;
    line-height: 1.4;
    transition: background .12s;
    font-size: .9rem;
}
.nav-dropdown-menu a:hover {
    background: var(--nav-hover);
    color: #fff;
}
.nav-dropdown-menu .dropdown-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,.12);
    margin: 4px 0;
}

/* ── PANEL / SECTION BOX ── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.panel-heading {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #f0f4f8;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    color: var(--nav-bg);
    font-family: 'Raleway', sans-serif;
}
.panel-body { padding: 16px; }
