/* ===== DESIGN TOKENS ===== */
:root {
    --bg-main:       #111214;
    --bg-sidebar:    #18191e;
    --bg-card:       #1f2128;
    --bg-input:      #272930;
    --bg-hover:      #2e3040;
    --accent:        #c9a84c;
    --accent-hover:  #b8952e;
    --accent-light:  rgba(201,168,76,.15);
    --text-primary:  #f0f1f5;
    --text-secondary:#9a9faf;
    --border:        #2c2e3a;
    --success:       #34d399;
    --danger:        #f87171;
    --warning:       #fbbf24;
    --sidebar-w:     270px;
    --radius:        12px;
    --radius-sm:     8px;
    --transition:    .2s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 16px;
}

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

/* ===== LAYOUT ===== */
#app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
#sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: transform var(--transition);
}

#sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px 16px;
    border-bottom: 1px solid var(--border);
}
#sidebar-logo {
    max-width: 150px;
    height: auto;
    object-fit: contain;
}

#sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 2px;
    cursor: pointer;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
}
.sidebar-link:hover, .sidebar-link:focus {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}
.sidebar-link.active {
    background: var(--accent-light);
    color: var(--accent);
}
.sidebar-link i { font-size: 1.05rem; flex-shrink: 0; }

.sidebar-link-btn { display: flex; }

.sidebar-sub { padding-left: 34px; font-size: .9375rem; }

.sidebar-group { margin-bottom: 2px; }

.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    background: transparent;
    border: none;
    width: 100%;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.sidebar-group-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-group-toggle > span { display: flex; align-items: center; gap: 10px; }
.sidebar-group-toggle > span i { font-size: 1.05rem; }
.sidebar-arrow { transition: transform var(--transition); font-size: .8rem; }
.sidebar-group-toggle.open .sidebar-arrow { transform: rotate(180deg); }

.sidebar-group-items { padding: 2px 0; }

#sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

/* ===== SIDEBAR TOGGLE (mobile) ===== */
#sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 1100;
    width: 42px; height: 42px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
#sidebar-toggle:hover { background: var(--bg-hover); }

/* ===== MAIN CONTENT ===== */
#main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#central {
    padding: 36px 32px;
    flex: 1;
}

/* ===== LOADER ===== */
#loader {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,11,14,.85);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
#loader.active { display: flex; }

.loader-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 1rem;
}

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

/* ===== MESSAGE OVERLAY ===== */
#message {
    position: fixed;
    inset: 0;
    background: rgba(10,11,14,.82);
    backdrop-filter: blur(4px);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 44px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.message-icon { font-size: 2.75rem; color: var(--accent); margin-bottom: 16px; }
.message-box p { color: var(--text-primary); margin-bottom: 24px; line-height: 1.65; font-size: 1rem; }

/* ===== CARDS ===== */
.card-dark {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.card-dark-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.card-dark-header h5 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}
.card-dark-header i { color: var(--accent); font-size: 1.15rem; }

/* ===== FORM ELEMENTS ===== */
.form-label {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 6px;
    display: block;
}

.form-control, .form-select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    padding: 12px 14px;
    font-size: 1rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(201,168,76,.2) !important;
    outline: none;
}
.form-control::placeholder { color: #4a4d5e; }
.form-control:disabled { opacity: .45; cursor: not-allowed; }

.form-select option { background: var(--bg-card); color: var(--text-primary); }

textarea.form-control { resize: vertical; min-height: 96px; }

.form-check-input {
    background-color: var(--bg-input);
    border-color: var(--border);
    width: 18px; height: 18px;
    cursor: pointer;
}
.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
.form-check-label { color: var(--text-secondary); font-size: 1rem; cursor: pointer; }

/* ===== BUTTONS ===== */
.btn-primary-dark {
    background: var(--accent);
    color: #111;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn-primary-dark:hover { background: var(--accent-hover); transform: translateY(-1px); color: #111; }

.btn-secondary-dark {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn-secondary-dark:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger-dark {
    background: rgba(248,113,113,.12);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,.3);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.btn-danger-dark:hover { background: rgba(248,113,113,.22); }

.btn-success-dark {
    background: rgba(52,211,153,.12);
    color: var(--success);
    border: 1px solid rgba(52,211,153,.3);
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: .9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-success-dark:hover { background: rgba(52,211,153,.22); }

.btn-sm-dark {
    padding: 7px 14px;
    font-size: .9375rem;
}

.btn-group-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* ===== TABLES ===== */
.table-dark-custom {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.table-dark-custom thead th {
    background: var(--bg-main);
    color: var(--text-secondary);
    font-size: .875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.table-dark-custom tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}
.table-dark-custom tbody tr:hover { background: var(--bg-hover); }
.table-dark-custom tbody td {
    padding: 14px 18px;
    color: var(--text-primary);
    font-size: 1rem;
    vertical-align: middle;
}
.table-dark-custom tbody tr:last-child { border-bottom: none; }

/* ===== IMAGES / MEDIA ===== */
.img-preview {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    display: none;
}

.img-preview-qr {
    width: 150px;
    height: 150px;
    object-fit: contain;
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 8px;
    display: none;
}

/* ===== FOTO UPLOAD ZONE ===== */
.foto-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    cursor: pointer;
    overflow: hidden;
    transition: border-color var(--transition), background var(--transition);
}
.foto-upload-zone:hover { border-color: var(--accent); background: var(--bg-hover); }

.foto-upload-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px 20px;
    gap: 10px;
    color: var(--text-secondary);
    transition: color var(--transition);
}
.foto-upload-empty i { font-size: 2.4rem; transition: color var(--transition); }
.foto-upload-empty span { font-size: .95rem; font-weight: 500; color: var(--text-primary); }
.foto-upload-empty small { font-size: .8rem; }
.foto-upload-zone:hover .foto-upload-empty i { color: var(--accent); }

.foto-upload-filled {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.foto-preview-wrap {
    position: relative;
    cursor: pointer;
}
.foto-preview-wrap img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    display: block;
    transition: filter var(--transition);
}
.foto-preview-wrap:hover img { filter: brightness(.35); }
.foto-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    transition: opacity var(--transition);
}
.foto-preview-wrap:hover .foto-upload-overlay { opacity: 1; }
.foto-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.foto-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.35);
    color: #fff;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
}
.foto-action-btn:hover .foto-action-icon { background: rgba(255,255,255,.35); transform: scale(1.1); }
.foto-action-btn > span {
    font-size: .72rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.9);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.foto-action-danger .foto-action-icon { border-color: rgba(248,113,113,.5); color: var(--danger); }
.foto-action-danger:hover .foto-action-icon { background: rgba(248,113,113,.4); }
.foto-action-danger > span { color: var(--danger); }

@media (hover: none) {
    .foto-upload-overlay { opacity: 1; }
    .foto-preview-wrap img { filter: brightness(.45); }
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 30px;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.page-header p { color: var(--text-secondary); font-size: 1.0625rem; }

/* ===== DASHBOARD CARDS ===== */
.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    transition: border-color var(--transition), transform var(--transition);
    height: 100%;
}
.dash-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.dash-card-icon {
    width: 46px; height: 46px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1.3rem;
    margin-bottom: 16px;
}
.dash-card h5 { font-size: 1.125rem; font-weight: 600; margin-bottom: 8px; }
.dash-card-links { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.dash-card-links a {
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 9px 10px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 7px;
}
.dash-card-links a:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.search-bar .form-control { flex: 1; }

/* ===== LOGIN PAGE ===== */
#login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-main);
    padding: 20px;
}
#login-box {
    width: 100%;
    max-width: 400px;
}
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand p { color: var(--text-secondary); font-size: 1rem; margin-top: 8px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
    #sidebar-toggle { display: flex; }
    #central { padding: 20px 16px; padding-top: 64px; }
}

/* ===== UTILITIES ===== */
.text-accent { color: var(--accent); }
.text-muted-dark { color: var(--text-secondary); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.badge-dark {
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: .8125rem;
    font-weight: 600;
}
