/* ============================================================
   AIO Course – Clean UI Framework
   White background, black text, green accent, mobile-first
   ============================================================ */

:root {
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 0px;
    --topbar-h: 56px;

    --brand: #16a34a;
    --brand-hover: #15803d;
    --brand-light: #f0fdf4;
    --brand-subtle: #dcfce7;

    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --bg-page: #f8fafc;
    --bg-white: #ffffff;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);

    --transition: 0.25s cubic-bezier(.4,0,.2,1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

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

::selection { background: var(--brand-subtle); color: var(--text-primary); }

/* ===== LAYOUT ===== */
#app-wrapper.no-transition,
#app-wrapper.no-transition .sidebar,
#app-wrapper.no-transition #main-area {
    transition: none !important;
}

#app-wrapper.no-side-switch-anim .sidebar {
    transition: none !important;
}

#app-wrapper { min-height: 100vh; }

#main-area {
    margin-left: var(--sidebar-w);
    margin-right: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition), margin-right var(--transition);
}

#app-wrapper.sidebar-right #main-area {
    margin-left: 0;
    margin-right: var(--sidebar-w);
}

#app-wrapper.sidebar-collapsed #main-area {
    margin-left: 0;
    margin-right: 0;
}

.main-content {
    flex: 1;
    padding: 28px 32px;
    width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition), width var(--transition);
}

#app-wrapper.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

#app-wrapper.sidebar-right .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
}

#app-wrapper.sidebar-right.sidebar-collapsed .sidebar {
    transform: translateX(100%);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.sidebar-brand { color: var(--text-primary); }
.sidebar-brand:hover { color: var(--text-primary); }

.brand-icon {
    width: 36px; height: 36px;
    background: var(--brand);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; color: #fff;
    flex-shrink: 0;
}

.brand-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-icon.brand-icon-logo {
    width: 160px;
    height: 50px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin-right: 0;
    position: relative;
    overflow: hidden;
}

.brand-logo-main {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.brand-logo-favicon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    object-position: center;
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
    transform: translateX(1px) scale(0.96);
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.brand-icon-logo.show-main .brand-logo-main {
    opacity: 1;
    transform: scale(1);
}

.brand-icon-logo.show-favicon .brand-logo-favicon {
    opacity: 1;
    transform: translateX(1px) scale(1);
}

@media (max-width: 1200px) {
    .brand-icon.brand-icon-logo {
        width: 36px;
        height: 36px;
    }
}

.nav-section-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 20px 14px 6px;
    font-weight: 600;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
    margin: 0 6px 2px;
}

.nav-link-item:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.nav-link-item.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}

.nav-link-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-link-item.active i { opacity: 1; }

.sidebar-footer {
    border-color: var(--border) !important;
    background: var(--bg-page);
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 28px;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar-toggle,
#sidebar-side-toggle {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
    flex-shrink: 0;
}

#sidebar-toggle:hover,
#sidebar-side-toggle:hover {
    background: var(--bg-page);
    color: var(--text-primary);
    border-color: #d1d5db;
}

#sidebar-side-toggle {
    color: var(--text-muted);
}

/* ===== CARDS ===== */
.content-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.content-card:hover {
    box-shadow: var(--shadow-xs);
}

a.content-card:hover {
    border-color: var(--brand-subtle);
    box-shadow: var(--shadow-sm);
}

.card-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.card-header-custom h6 {
    margin: 0;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.card-body-custom { padding: 20px; }

/* Stat cards */
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== TABLES ===== */
.table {
    --bs-table-bg: transparent;
    font-size: 0.82rem;
    margin-bottom: 0;
}

.table > thead > tr > th {
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 10px 16px;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table > tbody > tr:last-child > td { border-bottom: none; }
.table-hover > tbody > tr:hover > td { background: var(--bg-page); }

.table-custom { margin-bottom: 0; }
.table-custom thead th {
    background: var(--bg-page);
    border-bottom: 2px solid var(--border);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 10px 16px;
    white-space: nowrap;
}
.table-custom tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.82rem;
}
.table-custom tbody tr:hover { background: var(--bg-page); }

/* ===== BADGES ===== */
.badge {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-disabled { background: #fee2e2; color: #991b1b; }
.badge-revoked { background: #f1f5f9; color: #475569; }

.badge-super_admin { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #dbeafe; color: #1e40af; }
.badge-user { background: #e0f2fe; color: #075985; }

.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-todo, .badge-not_started, .badge-locked { background: #f1f5f9; color: #64748b; }
.badge-blocked, .badge-rejected, .badge-failed { background: #fee2e2; color: #991b1b; }
.badge-under_review, .badge-submitted { background: #e0e7ff; color: #3730a3; }
.badge-done, .badge-completed, .badge-approved { background: #dcfce7; color: #166534; }
.badge-needs_revision { background: #fed7aa; color: #9a3412; }
.badge-ready, .badge-info-soft { background: #e0f2fe; color: #075985; }
.badge-leader { background: #dcfce7; color: #166534; }
.badge-member { background: #f1f5f9; color: #475569; }
.badge-kicked { background: #fee2e2; color: #991b1b; }
.badge-left { background: #fef3c7; color: #92400e; }
.badge-agree { background: #fee2e2; color: #991b1b; }
.badge-disagree { background: #dcfce7; color: #166534; }
.badge-rich_text { background: #e0f2fe; color: #075985; }
.badge-file { background: #fef3c7; color: #92400e; }
.badge-external_link { background: #dbeafe; color: #1e40af; }
.badge-overdue { background: #fee2e2; color: #991b1b; }

/* ===== BUTTONS ===== */
.btn {
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn-brand {
    background: var(--brand);
    color: #fff;
    border: none;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    padding: 8px 18px;
}

.btn-brand:hover {
    background: var(--brand-hover);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22,163,74,0.25);
}

.btn-brand:active {
    transform: scale(0.98);
}

.btn-sm { font-size: 0.76rem; padding: 5px 12px; }

.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--bg-page);
    border-color: #d1d5db;
    color: var(--text-primary);
}

/* ===== FORMS ===== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.82rem;
    padding: 9px 14px;
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-text { font-size: 0.75rem; color: var(--text-muted); }

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* ===== LOGIN PAGE ===== */
.login-card {
    max-width: 420px;
    width: 100%;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 44px 40px;
}

.login-card .login-logo {
    width: 56px; height: 56px;
    background: var(--brand);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin: 0 auto 24px;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all var(--transition);
    text-decoration: none;
}

.btn-google:hover {
    background: var(--bg-page);
    border-color: #d1d5db;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-google img { width: 20px; height: 20px; }

/* ===== ACCESS DENIED ===== */
.access-denied-card {
    max-width: 480px;
    width: 100%;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px 40px;
    text-align: center;
}

.access-denied-card .icon-wrapper {
    width: 64px; height: 64px;
    background: #fee2e2;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px;
}

.access-denied-card .icon-wrapper i {
    font-size: 1.5rem;
    color: #dc2626;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.875rem;
    margin: 0;
    color: var(--text-secondary);
}

/* ===== PAGINATION ===== */
.pagination .page-link {
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    margin: 0 2px;
    color: var(--text-secondary);
    border-color: var(--border);
    padding: 6px 12px;
}

.pagination .page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
}

.pagination .page-link:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

/* ===== DROPDOWN ===== */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    padding: 6px;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.82rem;
}

.dropdown-item:hover, .dropdown-item:focus {
    background: var(--bg-page);
}

/* ===== MODAL ===== */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 18px 24px;
}

.modal-body { padding: 24px; }

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 14px 24px;
}

/* ===== ALERTS ===== */
.alert {
    border-radius: var(--radius);
    font-size: 0.82rem;
    padding: 12px 16px;
    border: none;
}

/* ===== BACK LINK ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 20px;
    transition: color var(--transition);
    font-weight: 500;
}

.back-link:hover { color: var(--brand); }

.back-link i { font-size: 0.9rem; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-header h4, .page-header h5 {
    margin: 0;
    font-weight: 700;
    color: var(--text-primary);
}

/* ===== PROGRESS BAR ===== */
.progress {
    border-radius: 20px;
    height: 6px;
    background: var(--border-light);
}

.progress-bar { border-radius: 20px; background: var(--brand); }

/* ===== AVATAR ===== */
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar-md { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* ===== NOTIFICATION DROPDOWN ===== */
.notif-dropdown {
    min-width: 360px;
    max-height: 420px;
    overflow-y: auto;
    padding: 0;
}

/* (backdrop removed — sidebar uses collapse toggle) */

/* ===== STEP PROGRESS ===== */
.step-link {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.step-link:hover { border-color: #d1d5db; color: var(--text-primary); }
.step-link.step-done { border-color: #86efac; background: #f0fdf4; color: #166534; }
.step-link.step-active { border-color: var(--brand); background: var(--brand-light); color: var(--brand); }
.step-link.step-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; background: var(--bg-page); }

/* ===== COURSE NAV ===== */
.course-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-page);
    border-radius: var(--radius);
    padding: 4px;
    border: 1px solid var(--border);
}

.course-nav .nav-btn {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}

.course-nav .nav-btn:hover { color: var(--text-primary); background: var(--bg-white); }
.course-nav .nav-btn.active { background: var(--bg-white); color: var(--brand); font-weight: 600; box-shadow: var(--shadow-xs); }

/* ===== TIMELINE ITEM ===== */
.timeline-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow var(--transition);
}

.timeline-item:hover { box-shadow: var(--shadow-xs); }

/* ===== ACTION GRID ===== */
.action-grid {
    display: grid;
    gap: 8px;
}

.action-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
}

.action-link:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}

.action-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ===== NOTIFICATION ROW ===== */
.notif-row { transition: background var(--transition); }
.notif-row:hover { background: var(--bg-page); }
.notif-unread { background: var(--brand-light); box-shadow: inset 3px 0 0 var(--brand); }
.notif-unread:hover { background: #e8faf0; }

/* ===== COURSE CARD (user dashboard) ===== */
.course-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all var(--transition);
}

.course-card:hover {
    border-color: var(--brand-subtle);
    box-shadow: var(--shadow-sm);
}

.course-card-body { padding: 20px 20px 12px; }

.course-card-footer {
    padding: 12px 20px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ===== SUBTASK ITEM (user dashboard) ===== */
.subtask-item {
    display: block;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all var(--transition);
}

.subtask-item:hover {
    border-color: var(--brand-subtle);
    background: var(--brand-light);
}

/* ===== UTILITIES ===== */
.text-brand { color: var(--brand) !important; }
.bg-brand-light { background: var(--brand-light) !important; }
.border-brand { border-color: var(--brand) !important; }
.fw-600 { font-weight: 600 !important; }
.fs-sm { font-size: 0.8rem !important; }
.fs-xs { font-size: 0.7rem !important; }
.gap-row { gap: 16px; }
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    #main-area {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .main-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    #sidebar-side-toggle { display: none !important; }

    .filter-bar .row > div { margin-bottom: 8px; }
    .table-responsive { border-radius: var(--radius); }

    .course-nav { overflow-x: auto; flex-wrap: nowrap; }
    .course-nav .nav-btn { flex-shrink: 0; }

    .notif-dropdown { min-width: 300px; }
}

@media (max-width: 575.98px) {
    .main-content { padding: 12px; }

    .login-card { margin: 12px; padding: 28px 20px; }
    .stat-card { padding: 14px; }
    .card-body-custom { padding: 14px; }
    .card-header-custom { padding: 12px 14px; }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header .btn-group,
    .page-header .d-flex { width: 100%; }

    .hide-mobile { display: none !important; }

    .stat-card .stat-value { font-size: 1.25rem; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar { display: none !important; }
    #main-area { margin-left: 0 !important; margin-right: 0 !important; }
    .main-content { padding: 0 !important; }
    .content-card { border: 1px solid #ddd; box-shadow: none; }
}
