/* ============================================
   Eduplus Attendance — Custom Style Override
   Soft, eye-friendly, purpose-built UI
   ============================================ */

:root {
    --ep-primary: #5b6abf;
    --ep-primary-light: #7c89d4;
    --ep-primary-dark: #3f4a8a;
    --ep-secondary: #6c757d;
    --ep-success: #4caf82;
    --ep-danger: #e05d5d;
    --ep-warning: #e8a838;
    --ep-info: #4a9fd5;
    --ep-bg: #f4f6fb;
    --ep-card-bg: #ffffff;
    --ep-sidebar-bg: #2c3252;
    --ep-sidebar-text: #c5cae9;
    --ep-sidebar-active: #5b6abf;
    --ep-text: #3a3f5c;
    --ep-text-muted: #8890a4;
    --ep-border: #e2e6ef;
    --ep-radius: 10px;
    --ep-shadow: 0 2px 12px rgba(91, 106, 191, 0.08);
    --ep-sidebar-width: 250px;
    --ep-sidebar-collapsed: 60px;
    --ep-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--ep-font);
    background: var(--ep-bg);
    color: var(--ep-text);
    font-size: 0.9rem;
    margin: 0;
    min-height: 100vh;
}

/* --- Sidebar --- */
.ep-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--ep-sidebar-width);
    height: 100vh;
    background: var(--ep-sidebar-bg);
    color: var(--ep-sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
    z-index: 1040;
    overflow: hidden;
}
.ep-sidebar.collapsed { width: var(--ep-sidebar-collapsed); }
.ep-sidebar .brand {
    padding: 18px 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ep-sidebar.collapsed .brand-text { display: none; }
.ep-sidebar .nav-menu { flex: 1; padding: 12px 0; overflow-y: auto; }
.ep-sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: var(--ep-sidebar-text);
    text-decoration: none;
    font-size: 0.88rem;
    border-radius: 6px;
    margin: 2px 8px;
    transition: all 0.15s;
    white-space: nowrap;
}
.ep-sidebar .nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ep-sidebar .nav-item.active { background: var(--ep-sidebar-active); color: #fff; }
.ep-sidebar .nav-item i { width: 24px; text-align: center; margin-right: 10px; font-size: 1rem; }
.ep-sidebar.collapsed .nav-item span { display: none; }
.ep-sidebar.collapsed .nav-item i { margin-right: 0; }

/* Sidebar footer */
.ep-sidebar .sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.ep-sidebar.collapsed .sidebar-footer .brand-text { display: none; }

/* --- Mobile sidebar overlay --- */
.ep-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.ep-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* --- Mobile hamburger toggle (hidden on desktop) --- */
.ep-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--ep-text);
    font-size: 1.4rem;
    padding: 4px 8px;
    cursor: pointer;
    line-height: 1;
}

/* --- Main Content --- */
.ep-main {
    margin-left: var(--ep-sidebar-width);
    padding: 24px 28px;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}
.ep-sidebar.collapsed ~ .ep-main { margin-left: var(--ep-sidebar-collapsed); }

/* --- Top Bar --- */
.ep-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}
.ep-topbar h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0;
    color: var(--ep-text);
}
.ep-topbar .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* --- Cards --- */
.ep-card {
    background: var(--ep-card-bg);
    border-radius: var(--ep-radius);
    box-shadow: var(--ep-shadow);
    border: 1px solid var(--ep-border);
    padding: 20px;
    margin-bottom: 20px;
}
.ep-stat-card {
    text-align: center;
    padding: 22px 16px;
}
.ep-stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ep-primary);
    line-height: 1;
}
.ep-stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--ep-text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Skeleton Loader --- */
.skeleton {
    background: linear-gradient(90deg, #eef1f7 25%, #dde2ee 50%, #eef1f7 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-stat { height: 36px; width: 80px; margin: 0 auto 8px; }
.skeleton-row { height: 42px; margin-bottom: 4px; }
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Tables --- */
.ep-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ep-table { width: 100%; border-collapse: collapse; }
.ep-table thead th {
    background: var(--ep-bg);
    padding: 10px 14px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ep-text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--ep-border);
    text-align: left;
    white-space: nowrap;
}
.ep-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--ep-border);
    font-size: 0.87rem;
    vertical-align: middle;
}
.ep-table tbody tr:hover { background: rgba(91, 106, 191, 0.03); }

/* --- Badges --- */
.ep-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.ep-badge-success { background: rgba(76,175,130,0.12); color: var(--ep-success); }
.ep-badge-danger { background: rgba(224,93,93,0.12); color: var(--ep-danger); }
.ep-badge-warning { background: rgba(232,168,56,0.12); color: var(--ep-warning); }
.ep-badge-info { background: rgba(74,159,213,0.12); color: var(--ep-info); }
.ep-badge-secondary { background: rgba(108,117,125,0.12); color: var(--ep-secondary); }

/* --- Buttons --- */
.btn-ep {
    background: var(--ep-primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-ep:hover { background: var(--ep-primary-dark); color: #fff; }
.btn-ep-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-ep-outline {
    background: transparent;
    color: var(--ep-primary);
    border: 1px solid var(--ep-primary);
}
.btn-ep-outline:hover { background: var(--ep-primary); color: #fff; }
.btn-ep-danger { background: var(--ep-danger); }
.btn-ep-danger:hover { background: #c94444; }

/* --- Forms --- */
.ep-form-group { margin-bottom: 16px; }
.ep-form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ep-text);
    margin-bottom: 5px;
}
.ep-form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--ep-border);
    border-radius: 6px;
    font-size: 0.87rem;
    color: var(--ep-text);
    background: #fff;
    transition: border-color 0.15s;
}
.ep-form-control:focus {
    outline: none;
    border-color: var(--ep-primary-light);
    box-shadow: 0 0 0 3px rgba(91,106,191,0.1);
}
.ep-form-error {
    font-size: 0.78rem;
    color: var(--ep-danger);
    margin-top: 4px;
}

/* --- Inline form row (used in webhooks, api-keys create sections) --- */
.ep-inline-form .row > [class*="col-"] {
    margin-bottom: 14px;
}

/* --- Filters Bar --- */
.ep-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 16px;
}
.ep-filters .ep-form-control { width: auto; min-width: 160px; }

/* --- Pagination --- */
.ep-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.ep-pagination button {
    padding: 6px 12px;
    border: 1px solid var(--ep-border);
    background: #fff;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    color: var(--ep-text);
}
.ep-pagination button.active { background: var(--ep-primary); color: #fff; border-color: var(--ep-primary); }
.ep-pagination button:disabled { opacity: 0.4; cursor: default; }

/* --- Impersonation Banner --- */
.ep-impersonate-bar {
    background: var(--ep-warning);
    color: #fff;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1050;
}
.ep-impersonate-bar ~ .ep-sidebar { top: 38px; height: calc(100vh - 38px); }
.ep-impersonate-bar ~ .ep-sidebar ~ .ep-main { padding-top: 62px; }

/* --- Login Page --- */
.ep-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ep-bg);
    padding: 16px;
}
.ep-login-card {
    width: 100%;
    max-width: 400px;
    padding: 36px;
    background: var(--ep-card-bg);
    border-radius: var(--ep-radius);
    box-shadow: var(--ep-shadow);
    border: 1px solid var(--ep-border);
}
.ep-login-card h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--ep-primary);
    font-weight: 700;
}

/* --- Select2 Override --- */
.select2-container--default .select2-selection--single {
    border: 1px solid var(--ep-border) !important;
    border-radius: 6px !important;
    height: 38px !important;
    padding: 4px 8px;
}
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--ep-border) !important;
    border-radius: 6px !important;
    min-height: 38px !important;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* --- Tablet (≤992px): Collapse sidebar by default --- */
@media (max-width: 992px) {
    .ep-sidebar {
        width: var(--ep-sidebar-collapsed);
    }
    .ep-sidebar .brand-text,
    .ep-sidebar .nav-item span,
    .ep-sidebar .sidebar-footer .brand-text { display: none; }
    .ep-sidebar .nav-item i { margin-right: 0; }
    .ep-main {
        margin-left: var(--ep-sidebar-collapsed);
        padding: 20px;
    }

    /* Inline form rows: let columns breathe */
    .ep-inline-form .row > [class*="col-"] {
        margin-bottom: 14px;
    }
}

/* --- Mobile (≤768px): Off-canvas sidebar + full-width layout --- */
@media (max-width: 768px) {
    /* Sidebar becomes off-canvas drawer */
    .ep-sidebar {
        width: var(--ep-sidebar-width);
        transform: translateX(-100%);
    }
    .ep-sidebar.mobile-open {
        transform: translateX(0);
    }
    /* Restore full labels when sidebar is open on mobile */
    .ep-sidebar.mobile-open .brand-text,
    .ep-sidebar.mobile-open .nav-item span,
    .ep-sidebar.mobile-open .sidebar-footer .brand-text { display: inline; }
    .ep-sidebar.mobile-open .nav-item i { margin-right: 10px; }

    /* Main content takes full width */
    .ep-main {
        margin-left: 0;
        padding: 16px;
    }

    /* Show hamburger */
    .ep-mobile-toggle { display: inline-flex; }

    /* Topbar */
    .ep-topbar h1 { font-size: 1.15rem; }

    /* Filters stack vertically */
    .ep-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .ep-filters .ep-form-control {
        width: 100%;
        min-width: 0;
    }

    /* Tables scroll hint */
    .ep-table { min-width: 600px; }

    /* Cards */
    .ep-card { padding: 14px; }
    .ep-stat-card { padding: 16px 12px; }
    .ep-stat-card .stat-value { font-size: 1.4rem; }

    /* Inline form rows in webhooks/api-keys: full-width stack */
    .ep-inline-form .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 14px;
    }
    .ep-inline-form .row {
        margin-bottom: 0;
    }

    /* Login card */
    .ep-login-card { padding: 24px 20px; }

    /* Action buttons wrap */
    .ep-table .d-flex.gap-1 { flex-wrap: wrap; }

    /* Impersonation bar adjustments */
    .ep-impersonate-bar ~ .ep-sidebar { top: 38px; height: calc(100vh - 38px); }
    .ep-impersonate-bar ~ .ep-sidebar ~ .ep-main { padding-top: 54px; }
}

/* --- Small mobile (≤480px) --- */
@media (max-width: 480px) {
    .ep-main { padding: 12px; }
    .ep-topbar { margin-bottom: 16px; }
    .ep-topbar h1 { font-size: 1.05rem; }
    .ep-card { padding: 12px; }
    .ep-stat-card .stat-value { font-size: 1.2rem; }
    .ep-stat-card .stat-label { font-size: 0.72rem; }
    .btn-ep { padding: 7px 14px; font-size: 0.82rem; }
    .btn-ep-sm { padding: 4px 10px; font-size: 0.76rem; }
    .ep-table thead th { padding: 8px 10px; font-size: 0.72rem; }
    .ep-table tbody td { padding: 8px 10px; font-size: 0.82rem; }
    .ep-pagination button { padding: 5px 9px; font-size: 0.78rem; }
}
