/* =====================================================================
   PICARS V2 dashboard theme — matched to the legacy INSPINIA look
   (dark navy #2f4050 sidebar, green #1ab394 accent, gray #f3f3f4 page,
   Open Sans). Presentation only; no markup/logic change.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
    --brand-dark: #2f4050;        /* sidebar */
    --brand-darker: #293846;      /* sidebar active/hover */
    --primary: #c0451f;           /* Picars brand orange (logo + login button) */
    --primary-600: #a23817;
    --primary-50: #fbeae3;

    --bg: #f3f3f4;                /* gray-bg page background */
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e7eaec;
    --border-strong: #dfe1e3;

    --text: #676a6c;             /* INSPINIA body text */
    --text-strong: #3a3f44;
    --text-muted: #9aa0a4;

    --success: #1ab394; --success-bg: #e7f7f3;
    --danger:  #ed5565; --danger-bg:  #fce8ea;
    --warning: #f8ac59; --warning-bg: #fef3e3;
    --info:    #1c84c6; --info-bg:    #e4f0f9;

    --radius: 4px;
    --radius-sm: 3px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

html, body {
    font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

/* ---- typography ---- */
h1 { font-size: 1.45rem; font-weight: 600; margin: 0 0 1rem; color: var(--text-strong); }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; color: var(--text-strong); }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; color: var(--text-strong); }
h1:focus { outline: none; }

a, .btn-link { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

/* ---- buttons (INSPINIA: flat, slightly rounded) ---- */
.btn,
button:not(.nav-link):not(.navbar-toggler):not(.lang-toggle) {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font-weight: 600; font-size: .82rem; line-height: 1;
    padding: .5rem .9rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn-primary, button[type="submit"]:not(.btn-link) {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.btn-primary:hover, button[type="submit"]:not(.btn-link):hover {
    background: var(--primary-600); border-color: var(--primary-600); color: #fff;
}
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

.btn-link, .btn.btn-link {
    background: none !important; border: none !important; padding: .25rem .4rem;
    color: var(--primary); font-weight: 600;
}
.btn-link:hover { color: var(--primary-600); text-decoration: underline; }
.btn-sm { padding: .28rem .5rem; font-size: .78rem; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
.form-control,
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    width: 100%; max-width: 360px;
    padding: .5rem .65rem; font-size: .85rem;
    color: var(--text-strong); background: #fff;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    transition: border-color .15s;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(192, 69, 31, .15);
}
::placeholder { color: #b3b8bb; }
label { font-weight: 600; font-size: .8rem; color: var(--text); display: inline-block; margin-bottom: .25rem; }
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--primary); vertical-align: middle; }

/* ---- cards (INSPINIA .ibox) ---- */
.card {
    background: #fff; border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}
.card-body { padding: 1.1rem 1.25rem; }
.card-body input, .card-body select, .card-body textarea { margin-bottom: .55rem; display: block; }

/* ---- tables (INSPINIA: clean, bordered) ---- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.table thead th {
    background: var(--surface-2); color: var(--text); font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em; text-align: start;
    padding: .65rem .85rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .85rem; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fbf2ee; }
.table td.actions { display: flex; flex-wrap: wrap; gap: .15rem; }

/* ---- INSPINIA titled card (.ibox) wrapping a grid ---- */
.card-head {
    padding: .65rem .9rem; border-bottom: 1px solid var(--border);
    font-weight: 600; color: var(--text); font-size: .92rem;
    display: flex; align-items: center; justify-content: space-between;
}
.card-head .head-actions { display: flex; gap: .4rem; align-items: center; }
.card > .table, .card .card-table { margin: 0; border: none; border-radius: 0; box-shadow: none; }
.card > .table thead th:first-child { border-radius: 0; }

/* ---- status pills (legacy badge look) ---- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: .7rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.pill-ok     { background: var(--success-bg); color: #15795f; }
.pill-off    { background: #f0f1f2;           color: #82888c; }
.pill-warn   { background: var(--warning-bg); color: #b06a13; }
.pill-danger { background: var(--danger-bg);  color: #a94442; }
.pill-info   { background: var(--info-bg);    color: #1b5a86; }

/* ---- fleet-status bars (dashboard, no external chart lib) ---- */
.statbars { display: flex; flex-direction: column; gap: .7rem; padding: 1rem 1.25rem; }
.statbar { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: .7rem; }
.statbar .sb-label { font-size: .78rem; color: var(--text); font-weight: 600; }
.statbar .sb-track { height: 10px; background: #eef0f1; border-radius: 6px; overflow: hidden; }
.statbar .sb-fill  { height: 100%; border-radius: 6px; transition: width .3s; }
.statbar .sb-val   { font-size: .82rem; font-weight: 700; color: var(--text-strong); text-align: end; }
.sb-online  { background: var(--success); }
.sb-offline { background: #b3b8bb; }
.sb-armed   { background: var(--info); }
.sb-tamper  { background: var(--danger); }
.sb-pending { background: var(--warning); }

/* ---- alerts ---- */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 1rem; font-size: .85rem; }
.alert-danger  { background: var(--danger-bg);  color: #a94442; border-color: #f3c6cb; }
.alert-success { background: var(--success-bg); color: #15795f; border-color: #b9e6db; }
.alert-info    { background: var(--info-bg);     color: #1b5a86; border-color: #bcdcf0; }

/* ---- toolbar / pager ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.1rem; }
.toolbar .search { max-width: 300px; margin: 0; }
.pager { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.pager .page-info { color: var(--text-muted); font-size: .82rem; font-weight: 600; }

/* ---- empty states ---- */
.no-devices, .no-data, .loading, .no-events, .no-customers, .no-agents, .no-distributors,
.no-contacts, .no-geofences, .no-cameras, .no-triggers, .no-plugins, .no-serials,
.no-visit-reports, .no-users, .no-languages, .no-translations, .no-employees, .no-tickets, .no-logs {
    color: var(--text-muted); padding: 2rem; text-align: center; background: #fff;
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* ---- login (creative split hero + glass form) ---- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 12% -10%, rgba(192, 69, 31, .10), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(31, 39, 51, .10), transparent 55%),
        #eef1f4;
}
.login-shell {
    width: 100%; max-width: 960px; min-height: 580px;
    display: grid; grid-template-columns: 1.05fr .95fr;
    background: #fff; border-radius: 22px; overflow: hidden;
    box-shadow: 0 30px 80px -24px rgba(20, 24, 31, .45), 0 2px 6px rgba(20, 24, 31, .08);
}

/* hero (brand) panel */
.login-hero {
    position: relative; overflow: hidden; color: #fff;
    padding: 3rem 2.75rem;
    display: flex; align-items: center;
    background:
        radial-gradient(120% 120% at 0% 0%, #2a323e 0%, #1a1f27 55%, #12161c 100%);
}
.login-hero .hero-glow {
    position: absolute; width: 460px; height: 460px; border-radius: 50%;
    inset-inline-start: -120px; inset-block-end: -160px;
    background: radial-gradient(circle, rgba(255, 122, 69, .55), rgba(192, 69, 31, .22) 45%, transparent 70%);
    filter: blur(8px); animation: heroPulse 7s ease-in-out infinite;
}
@keyframes heroPulse { 0%, 100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.18); opacity: 1; } }
.login-hero .hero-content { position: relative; z-index: 2; width: 100%; }
.login-hero .hero-logo { display: flex; align-items: center; gap: .65rem; margin-bottom: 2.2rem; }
.login-hero .hero-logo .logo { width: 60px; height: 60px; filter: drop-shadow(0 4px 14px rgba(255, 122, 69, .45)); }
.login-hero .hero-logo .wordmark { font-size: 2.4rem; font-weight: 700; letter-spacing: -.02em; }
.login-hero .hero-title { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin: 0 0 .6rem; }
.login-hero .hero-sub { font-size: 1rem; color: rgba(255, 255, 255, .72); margin: 0 0 2rem; }
.login-hero .hero-features { list-style: none; padding: 0; margin: 0; display: grid; gap: .9rem; }
.login-hero .hero-features li { display: flex; align-items: center; gap: .8rem; font-size: .94rem; color: rgba(255, 255, 255, .9); }
.login-hero .hero-features i {
    width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
    display: inline-flex; align-items: center; justify-content: center; font-size: .95rem;
    color: #ff8a5c; background: rgba(255, 122, 69, .14); border: 1px solid rgba(255, 122, 69, .28);
}

/* floating embers */
.login-hero .embers { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.login-hero .ember {
    position: absolute; bottom: -12px; width: 6px; height: 6px; border-radius: 50%;
    background: radial-gradient(circle, #ffb38a, #ff7a45 60%, rgba(192,69,31,0) 72%);
    opacity: 0; animation: emberRise 6s linear infinite;
}
@keyframes emberRise {
    0% { transform: translateY(0) scale(.6); opacity: 0; }
    15% { opacity: .9; }
    80% { opacity: .7; }
    100% { transform: translateY(-560px) translateX(24px) scale(1.1); opacity: 0; }
}
.login-hero .e0  { left: 6%;  animation-delay: .0s;  animation-duration: 6.5s; }
.login-hero .e1  { left: 14%; animation-delay: 1.6s; animation-duration: 7.4s; }
.login-hero .e2  { left: 22%; animation-delay: .8s;  animation-duration: 5.8s; }
.login-hero .e3  { left: 31%; animation-delay: 2.7s; animation-duration: 8.1s; }
.login-hero .e4  { left: 40%; animation-delay: .3s;  animation-duration: 6.9s; width: 5px; height: 5px; }
.login-hero .e5  { left: 49%; animation-delay: 3.4s; animation-duration: 7.7s; }
.login-hero .e6  { left: 58%; animation-delay: 1.1s; animation-duration: 6.2s; }
.login-hero .e7  { left: 66%; animation-delay: 2.2s; animation-duration: 8.6s; width: 4px; height: 4px; }
.login-hero .e8  { left: 74%; animation-delay: .6s;  animation-duration: 7.0s; }
.login-hero .e9  { left: 82%; animation-delay: 3.9s; animation-duration: 6.6s; }
.login-hero .e10 { left: 90%; animation-delay: 1.9s; animation-duration: 7.9s; width: 5px; height: 5px; }
.login-hero .e11 { left: 96%; animation-delay: 2.9s; animation-duration: 6.4s; }

/* form panel */
.login-form-panel { display: flex; align-items: center; justify-content: center; padding: 3rem 2.75rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card .form-head { margin-bottom: 1.8rem; }
.login-card .form-head h2 { font-size: 1.7rem; font-weight: 700; color: #1f2733; margin: 0 0 .25rem; }
.login-card .form-head .muted { color: #8a8d8f; font-size: .95rem; margin: 0; }
.login-page form { display: flex; flex-direction: column; gap: 1rem; }
.login-card .field { position: relative; display: block; }
.login-card .field > i {
    position: absolute; inset-inline-start: 1rem; top: 50%; transform: translateY(-50%);
    color: #9aa0a6; font-size: .95rem; pointer-events: none; transition: color .15s ease;
}
.login-card .field .form-control {
    width: 100%; padding: .85rem 1rem; padding-inline-start: 2.7rem; font-size: .95rem;
    color: #1f2733; background: #f5f6f8; border: 1.5px solid #e3e6ea; border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-card .field .form-control::placeholder { color: #9aa0a6; opacity: 1; }
.login-card .field .form-control:focus {
    outline: none; background: #fff; border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(192, 69, 31, .14);
}
.login-card .field:focus-within > i { color: var(--primary); }
.login-page .submit, .login-page button[type="submit"] {
    width: 100%; padding: .9rem; margin-top: .35rem; font-size: 1rem; font-weight: 600;
    color: #fff; border: none; border-radius: 12px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    background: linear-gradient(135deg, #d9512a 0%, #c0451f 60%, #a5380f 100%);
    box-shadow: 0 10px 24px -8px rgba(192, 69, 31, .6);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.login-page .submit:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 14px 30px -8px rgba(192, 69, 31, .7); }
.login-page .submit:active { transform: translateY(0); }
.login-page .error {
    display: flex; align-items: center; gap: .5rem; margin-top: .9rem;
    color: #b53a16; background: rgba(192, 69, 31, .08); border: 1px solid rgba(192, 69, 31, .2);
    padding: .6rem .8rem; border-radius: 10px; font-size: .85rem;
}
.login-foot { margin-top: 1.6rem; color: #a7abb0; font-size: .8rem; text-align: center; }

@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; max-width: 440px; min-height: 0; }
    .login-hero { display: none; }
    .login-form-panel { padding: 2.5rem 1.75rem; }
    .login-card { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
    .login-hero .hero-glow, .login-hero .ember { animation: none; }
    .login-hero .ember { opacity: 0; }
}

/* ---- TV Wall (full-screen control-room view, /tv) ---- */
.tv {
    position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
    padding: 1.6rem 2rem; gap: 1.4rem; overflow: hidden;
    background:
        radial-gradient(1000px 500px at 100% 0%, rgba(192,69,31,.14), transparent 60%),
        linear-gradient(160deg, #12161c 0%, #0d1116 100%);
    color: #eef1f4; font-feature-settings: "tnum";
}
.tv-top { display: flex; align-items: center; justify-content: space-between; }
.tv-brand { font-size: 2rem; font-weight: 800; letter-spacing: .04em; }
.tv-brand span { color: #ff7a45; font-weight: 600; letter-spacing: 0; }
.tv-exit {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; color: #cfd4da; text-decoration: none; font-size: 1.3rem;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
}
.tv-exit:hover { background: rgba(231,76,60,.2); color: #fff; }

.tv-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.1rem; }
.tv-kpi {
    background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 16px;
    padding: 1.4rem 1rem; text-align: center;
}
.tv-kpi .v { font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 800; line-height: 1; }
.tv-kpi .l { margin-top: .5rem; font-size: 1rem; color: #aab0b8; text-transform: uppercase; letter-spacing: .08em; }
.tv-kpi.ok .v { color: #2ecc71; }
.tv-kpi.warn .v { color: #f39c12; }
.tv-kpi.danger .v { color: #e74c3c; }

.tv-events {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
    background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 1.2rem 1.4rem;
}
.tv-h { font-size: 1.2rem; font-weight: 700; color: #cfd4da; margin-bottom: .8rem; letter-spacing: .04em; }
.tv-events { overflow-y: auto; }
.tv-row {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 1rem; align-items: center;
    padding: .85rem 1rem; border-radius: 10px; font-size: 1.25rem;
    border-inline-start: 4px solid transparent; background: rgba(255,255,255,.02);
}
.tv-row + .tv-row { margin-top: .5rem; }
.tv-row .dev { font-weight: 700; }
.tv-row .kind { color: #aab0b8; }
.tv-row .time { color: #8a9099; font-variant-numeric: tabular-nums; }
.tv-row.fire { border-inline-start-color: #e74c3c; background: rgba(231,76,60,.12); }
.tv-row.fire .kind { color: #ff8a7a; }
.tv-row.fault { border-inline-start-color: #f39c12; background: rgba(243,156,18,.10); }
.tv-row.fault .kind { color: #f6c97a; }
.tv-empty, .tv-loading { margin: auto; color: #8a9099; font-size: 1.3rem; padding: 2rem; text-align: center; }

@media (max-width: 900px) {
    .tv-kpis { grid-template-columns: repeat(2, 1fr); }
    .tv-row { grid-template-columns: 1fr auto; font-size: 1.05rem; }
    .tv-row .kind { display: none; }
}

/* ---- page error fallback (ErrorBoundary) ---- */
.page-error {
    margin: 2rem auto; max-width: 520px; text-align: center; padding: 2rem;
    background: #fff; border: 1px solid var(--border-strong, #e3e6ea); border-radius: 14px;
    color: var(--text-muted, #6b7178);
}
.page-error i { font-size: 2rem; color: var(--primary); display: block; margin-bottom: .8rem; }
.page-error .reload {
    display: inline-block; margin-top: 1rem; padding: .5rem 1.2rem; border-radius: 8px;
    background: var(--primary); color: #fff; text-decoration: none;
}

/* ---- dashboard KPI tiles (INSPINIA widget) ---- */
.summary-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .9rem !important; margin-bottom: 1.5rem;
}
.summary-cards .col { width: auto; padding: 0; max-width: none; }
.summary-cards .card { margin-bottom: 0; height: 100%; border-top: 3px solid var(--border-strong); }
.summary-cards .card-body { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.15rem; }
.summary-cards .metric { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--text-strong); }
.summary-cards .label { font-size: .72rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.metric-total    { border-top-color: var(--info) !important; }
.metric-online   { border-top-color: var(--success) !important; }
.metric-online .metric { color: var(--success); }
.metric-offline, .metric-disarmed { border-top-color: #b3b8bb !important; }
.metric-armed    { border-top-color: var(--info) !important; }
.metric-tamper   { border-top-color: var(--danger) !important; }
.metric-tamper .metric { color: var(--danger); }
.metric-pending  { border-top-color: var(--warning) !important; }
.metric-pending .metric { color: var(--warning); }

/* ---- RTL ---- */
[dir="rtl"] .toolbar, [dir="rtl"] .pager { flex-direction: row-reverse; }
[dir="rtl"] .table thead th, [dir="rtl"] .table tbody td { text-align: right; }

/* ---- error UI ---- */
.blazor-error-boundary { background: var(--danger); padding: 1rem 1.5rem; color: #fff; border-radius: var(--radius-sm); }
.blazor-error-boundary::after { content: "An error has occurred."; }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); }
