/* ============================================
   Alnoor Portal - Stylesheet
   Poppins font, teal/emerald theme
   ============================================ */

/* ---- CSS Variables (Light Theme) ---- */
:root {
    --sidebar-bg: #0F3D3E;
    --sidebar-hover: #1A5C5E;
    --sidebar-active: #247577;
    --sidebar-text: #B2DFDB;
    --sidebar-text-active: #FFFFFF;
    --sidebar-width: 68px;
    --sidebar-expanded: 220px;

    --page-bg: #F1F5F9;
    --card-bg: #FFFFFF;
    --card-border: #E2E8F0;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.08);

    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    --border-color: #E2E8F0;
    --input-bg: #FFFFFF;
    --input-border: #CBD5E1;
    --input-focus: #14B8A6;

    --primary: #0F766E;
    --primary-light: #14B8A6;
    --primary-dark: #0D5D56;

    --success: #10B981;
    --success-light: #D1FAE5;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    --gold: #D97706;
    --gold-light: #FEF3C7;

    /* Card gradients */
    --grad-teal: linear-gradient(135deg, #0F766E 0%, #14B8A6 100%);
    --grad-indigo: linear-gradient(135deg, #4338CA 0%, #6366F1 100%);
    --grad-amber: linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
    --grad-rose: linear-gradient(135deg, #E11D48 0%, #FB7185 100%);
    --grad-slate: linear-gradient(135deg, #475569 0%, #64748B 100%);

    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: 0.2s ease;
}

/* ---- Dark Theme ---- */
[data-theme="dark"] {
    --sidebar-bg: #0A2526;
    --sidebar-hover: #0F3D3E;
    --sidebar-active: #1A5C5E;

    --page-bg: #0F172A;
    --card-bg: #1E293B;
    --card-border: #334155;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.3);

    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --border-color: #334155;
    --input-bg: #1E293B;
    --input-border: #475569;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--page-bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

img { max-width: 100%; height: auto; }

code, pre {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--page-bg);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

pre {
    padding: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---- Login Page ---- */
.login-body {
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header { margin-bottom: 28px; }

.login-logo {
    width: 60px;
    height: 60px;
    background: var(--grad-teal);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-footer-text {
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
    margin-top: 20px;
}

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}

.sidebar:hover {
    width: var(--sidebar-expanded);
}

.sidebar-logo {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.logo-text {
    width: 38px;
    height: 38px;
    background: var(--grad-teal);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 400;
    transition: all var(--transition);
    white-space: nowrap;
    gap: 14px;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--primary-light);
    font-weight: 500;
}

.sidebar-label {
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar:hover .sidebar-label {
    opacity: 1;
}

.sidebar-footer {
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

/* ---- Mobile Header ---- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--sidebar-bg);
    color: white;
    align-items: center;
    padding: 0 16px;
    z-index: 90;
    gap: 12px;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
}

.mobile-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.1rem;
}

.mobile-logout {
    color: white;
    font-size: 1.3rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 95;
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title i {
    color: var(--primary);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-gold    { background: var(--gold-light); color: var(--gold); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-success { background: var(--success-light); color: #059669; }
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: #B45309; }
.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-verified { background: #D1FAE5; color: #065F46; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success { background: var(--success-light); color: #065F46; border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light); color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400E; border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light); color: #1E40AF; border-left: 4px solid var(--info); }

/* ---- Summary Cards (Dashboard) ---- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid transparent;
}

.summary-card-teal   { border-left-color: #14B8A6; }
.summary-card-indigo { border-left-color: #6366F1; }
.summary-card-amber  { border-left-color: #F59E0B; }
.summary-card-rose   { border-left-color: #FB7185; }

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: white;
    flex-shrink: 0;
}

.summary-card-teal .summary-icon   { background: var(--grad-teal); }
.summary-card-indigo .summary-icon { background: var(--grad-indigo); }
.summary-card-amber .summary-icon  { background: var(--grad-amber); }
.summary-card-rose .summary-icon   { background: var(--grad-rose); }

.summary-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.summary-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

/* ---- Module Cards Grid ---- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.module-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}

.module-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
}

.module-card-header {
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
}

.card-gradient-teal   { background: var(--grad-teal); }
.card-gradient-indigo { background: var(--grad-indigo); }
.card-gradient-amber  { background: var(--grad-amber); }
.card-gradient-rose   { background: var(--grad-rose); }
.card-gradient-slate  { background: var(--grad-slate); }

.module-card-body {
    padding: 18px 20px 20px;
}

.module-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.module-card-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

/* ---- Content Card ---- */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.filter-card {
    padding: 16px 20px;
    margin-bottom: 16px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover { background: var(--primary); color: white; border-color: var(--primary); }

.btn-light {
    background: var(--page-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-light:hover { background: var(--border-color); color: var(--text-primary); }

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger-outline:hover { background: var(--danger); color: white; }

.btn-success-outline {
    background: transparent;
    color: var(--success);
    border: 1px solid var(--success);
}
.btn-success-outline:hover { background: var(--success); color: white; }

.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-xs { padding: 3px 8px; font-size: 0.75rem; }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 18px;
}

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

.form-label i {
    margin-right: 4px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-control-sm {
    padding: 7px 10px;
    font-size: 0.8rem;
}

select.form-control {
    appearance: auto;
}

.form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ---- Checkbox ---- */
.checkbox-wrapper {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.checkbox-wrapper input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ---- Tables ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.data-table th {
    background: var(--page-bg);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: rgba(20, 184, 166, 0.04);
}

.data-table .text-center { text-align: center; }
.data-table .text-right  { text-align: right; }
.data-table .text-nowrap { white-space: nowrap; }

.actions-cell {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

/* ---- Filters ---- */
.filter-form { }
.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 140px;
}

.filter-group .form-label {
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.filter-actions {
    display: flex;
    gap: 6px;
    min-width: auto;
    flex: 0;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 12px;
}

.modal-body h4:first-child { margin-top: 0; }

/* ---- Permissions Table ---- */
.permissions-table td i {
    margin-right: 8px;
    color: var(--primary);
}

/* ---- Helpers ---- */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-nowrap { white-space: nowrap; }

.mb-0  { margin-bottom: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-expanded);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .sidebar .sidebar-label {
        opacity: 1;
    }

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

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 72px 16px 24px;
    }

    .page-header {
        flex-direction: column;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
    }

    .filter-actions {
        flex-direction: row;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .actions-cell {
        flex-direction: column;
        gap: 2px;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 30px 20px;
    }
}

/* ---- Print Styles ---- */
@media print {
    .sidebar, .mobile-header, .filter-card, .btn, .form-actions, .pagination { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    .content-card { box-shadow: none; border: 1px solid #ddd; }
    body { background: white; }
}
