/* =====================================================
   CREDO ADMIN – EOS DESIGN SYSTEM
   Mobile First | CIO Grade | Stable Layout
===================================================== */

/* ---------- DESIGN TOKENS ---------- */
:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;

    --text-primary: #0f172a;
    --text-muted: #64748b;

    --border-light: #e5e7eb;

    --brand-dark: #0f172a;
    --brand-accent: #1e3a8a;

    --danger: #dc2626;
    --info-bg: #e0e7ff;
}

/* ---------- RESET ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
}

/* =====================================================
   ADMIN LAYOUT (CANONICAL)
===================================================== */

.admin-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

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

.content {
    padding: 16px;
    flex: 1;
}

@media (min-width: 1024px) {
    .content {
        padding: 24px;
    }
}

/* =====================================================
   SIDEBAR (MOBILE FIRST, SINGLE MODEL)
===================================================== */

.sidebar {
    width: 260px;
    background: var(--brand-dark);
    color: #e5e7eb;
    padding: 18px 16px;
    overflow-y: auto;
    z-index: 1000;

    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;

    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.sidebar.open {
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .sidebar {
        position: relative;
        transform: none;
        height: auto;
    }
}

/* ---------- SIDEBAR BRAND ---------- */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.sidebar-brand img {
    max-height: 42px;
}

.brand-text {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

/* ---------- SIDEBAR NAV ---------- */
.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
    color: #cbd5f5;
    text-decoration: none;
    margin-bottom: 4px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--brand-accent);
    color: #ffffff;
    font-weight: 600;
}

.nav-section {
    margin: 18px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    color: #94a3b8;
}

.sidebar-nav .logout {
    margin-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 16px;
    color: #fca5a5;
}

/* ---------- OVERLAY ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 900;
}

.sidebar-overlay.show {
    display: block;
}

@media (min-width: 1024px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* =====================================================
   TOPBAR
===================================================== */

.topbar {
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-light);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    width: 40px;
    height: 40px;
    font-size: 20px;
    background: none;
    border: none;
    cursor: pointer;
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.admin-role {
    display: none;
    font-size: 12px;
    background: var(--info-bg);
    color: var(--brand-accent);
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
}

.logout-link {
    font-size: 13px;
    color: var(--danger);
    text-decoration: none;
}

@media (min-width: 640px) {
    .admin-role {
        display: inline-flex;
    }
}

@media (min-width: 1024px) {
    .menu-toggle {
        display: none;
    }
}

/* =====================================================
   PAGE HEADER
===================================================== */

.page-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.page-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

@media (min-width: 768px) {
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* =====================================================
   BUTTONS
===================================================== */

.btn-primary {
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--brand-accent);
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.btn-primary:hover {
    background: #1e40af;
}

.btn-secondary {
    padding: 10px 14px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

/* =====================================================
   TABLES
===================================================== */

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    margin-top: 10px;
}

.admin-table th,
.admin-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    text-align: left;
}

.admin-table th {
    background: #f8fafc;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

/* =====================================================
   ADMIN FORMS
===================================================== */

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.admin-form input,
.admin-form select {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    font-size: 14px;
}

.admin-form input:focus,
.admin-form select:focus {
    outline: none;
    border-color: var(--brand-accent);
}

.form-divider {
    border: none;
    border-top: 1px solid var(--border-light);
}

/* =====================================================
   AUTH / LOGIN
===================================================== */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    padding: 36px 32px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    box-shadow: 0 10px 30px rgba(15,23,42,0.08);
    text-align: center;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 14px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.login-card button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--brand-dark);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
}

/* =====================================================
   MODALS
===================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5vh auto;
    padding: 0;
    border: 1px solid #e2e8f0;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close {
    color: #94a3b8;
    font-size: 28px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-divider {
    border: 0;
    border-top: 1px solid var(--border-light);
    margin: 24px 0;
}

/* Modal Form Styles */
.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 120px;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.dense-table th, .dense-table td {
    padding: 8px 12px;
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
    font-size: 13px;
    font-weight: 500;
}

.btn-text-danger:hover {
    text-decoration: underline;
}

/* =====================================================
   DASHBOARD / STATS
===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e1;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--brand-dark);
    margin-bottom: 4px;
}

.stat-hint {
    font-size: 13px;
    color: #94a3b8;
}

/* Dashboard Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .details-grid {
        grid-template-columns: 2fr 1fr;
    }
}

.detail-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.detail-card h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--brand-dark);
}

/* Action List Styles */
.action-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.action-item:hover {
    background: #ffffff;
    border-color: var(--brand-accent);
    transform: translateX(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.action-item span:first-child {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--brand-accent);
}

.action-item span:last-child {
    font-size: 12px;
    color: var(--text-muted);
}
