/* ===========================================================
   NSD Fasad App - Dark Theme + Lime Green Accent
   Vanilla CSS only (Grid + Flexbox), no framework - matches
   Central Hub's dark/lime palette (see assets/css/style.css there).
   Breakpoints: desktop >=1024px, tablet 768-1023px, mobile <=767px.
   =========================================================== */

:root {
    --bg: #1a1a1a;
    --bg-elevated: #232323;
    --bg-card: #262626;
    --bg-input: #2e2e2e;
    --border: #3a3a3a;
    --text: #e0e0e0;
    --text-dim: #9c9c9c;
    --accent: #39FF14;
    --accent-dim: #2bc410;
    --accent-text: #0d1a05;
    --danger: #ff5c5c;
    --warning: #ffb84d;
    --success: #39FF14;
    --info: #4dd2ff;
    --radius: 8px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: #fff; margin: 0 0 0.5em 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.75em 0; }

/* ---------------- Layout shell (app-shell injected by app.js) ---------------- */

#app-shell {
    display: flex;
    min-height: 100vh;
}

#sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}

#sidebar .brand {
    padding: 0 1.25rem 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

#sidebar nav a {
    display: block;
    padding: 0.65rem 1.25rem;
    color: var(--text);
    border-left: 3px solid transparent;
}

#sidebar nav a:hover, #sidebar nav a.active {
    background: var(--bg-card);
    border-left-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

#sidebar .sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 1.25rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}

#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

#topbar .user-info { display: flex; align-items: center; gap: 0.75rem; }
#topbar .role-badge {
    background: var(--accent);
    color: var(--accent-text);
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

#page-content {
    padding: 1.5rem;
    flex: 1;
}

/* Mobile hamburger toggle (hidden on desktop) */
#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
}

/* ---------------- Cards / panels ---------------- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.card h2, .card h3 { margin-top: 0; }

/* ---------------- Stat cards (3-stat summary) ---------------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    text-align: center;
}

.stat-card .stat-emoji { font-size: 1.6rem; }
.stat-card .stat-label { color: var(--text-dim); font-size: 0.85rem; margin: 0.25rem 0; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-card .stat-count { color: var(--text-dim); font-size: 0.85rem; }

/* ---------------- Forms ---------------- */

label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-dim);
    font-size: 0.88rem;
}

.form-group { margin-bottom: 1rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="tel"], input[type="search"],
select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
}

textarea { min-height: 90px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.25);
}

input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; vertical-align: middle; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }

.form-hint { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.25rem; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: 0.25rem; }

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 700;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 92, 92, 0.12); }

.btn-sm { min-height: 34px; padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th { color: var(--text-dim); font-weight: 600; background: var(--bg-elevated); }
tr:hover td { background: rgba(57, 255, 20, 0.04); }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}
.badge-new { color: var(--info); border-color: var(--info); }
.badge-assigned { color: var(--warning); border-color: var(--warning); }
.badge-on_progress { color: var(--warning); border-color: var(--warning); }
.badge-completed { color: var(--accent); border-color: var(--accent); }
.badge-verified { color: var(--accent); border-color: var(--accent); }
.badge-cancelled { color: var(--danger); border-color: var(--danger); }

/* ---------------- Pagination ---------------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-close {
    float: right;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.3rem;
    cursor: pointer;
}

/* ---------------- Toast ---------------- */

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 90vw;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
    min-width: 240px;
    animation: toast-in 0.2s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Spinner ---------------- */

.spinner {
    width: 20px; height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: center; justify-content: center;
    z-index: 3000;
}
.spinner-overlay.hidden { display: none; }
.spinner-overlay .spinner { width: 40px; height: 40px; border-width: 4px; }

/* ---------------- Photo gallery / lightbox ---------------- */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.photo-thumb {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    aspect-ratio: 1;
    background: var(--bg-elevated);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-type-label {
    position: absolute; top: 4px; left: 4px;
    background: rgba(0,0,0,0.65);
    color: var(--accent);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}
.photo-thumb .verified-badge {
    position: absolute; bottom: 4px; right: 4px;
    background: rgba(0,0,0,0.65);
    color: var(--accent);
    font-size: 0.9rem;
    padding: 0 0.3rem;
    border-radius: 4px;
}
.photo-placeholder {
    display: flex; align-items: center; justify-content: center;
    aspect-ratio: 1;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 0.85rem;
    text-align: center;
    padding: 0.5rem;
}

.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 4000;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column;
    gap: 1rem;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 75vh; border-radius: var(--radius); }
.lightbox-controls { display: flex; gap: 1rem; align-items: center; }
.lightbox-close { position: absolute; top: 1rem; right: 1.5rem; font-size: 2rem; color: #fff; background: none; border: none; cursor: pointer; }

/* ---------------- Misc utility ---------------- */

.text-dim { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .brand-title { text-align: center; color: var(--accent); font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-card .brand-sub { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1.5rem; }

/* ---------------- Responsive breakpoints ---------------- */

/* Tablet */
@media (max-width: 1023px) {
    .stat-row { grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
    #sidebar { width: 180px; }
}

/* Mobile */
@media (max-width: 767px) {
    #sidebar-toggle { display: inline-block; }
    #sidebar {
        position: fixed;
        left: -240px;
        top: 0; bottom: 0;
        width: 220px;
        z-index: 1500;
        transition: left 0.2s ease;
    }
    #sidebar.open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
    #page-content { padding: 1rem; }
    .stat-row { grid-template-columns: 1fr; }
    table { font-size: 0.82rem; }
    th, td { padding: 0.5rem; }
    .form-row { flex-direction: column; }
    .btn { width: 100%; }
    .btn.btn-inline { width: auto; }
}
