/* ================================================
   Cognia Candidacy Workbook - Main Stylesheet
   ================================================ */

:root {
    --primary:    #c0392b;
    --primary-dk: #96281b;
    --secondary:  #2c3e50;
    --accent:     #e74c3c;
    --bg:         #f4f6f9;
    --card-bg:    #ffffff;
    --border:     #dde1e7;
    --text:       #2c3e50;
    --text-muted: #7f8c8d;
    --success:    #27ae60;
    --warning:    #f39c12;
    --input-bg:   #fafbfc;
    --radius:     8px;
    --shadow:     0 2px 12px rgba(0,0,0,0.09);
    --sidebar-w:  260px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 15px;
}

body.rtl { direction: rtl; font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif; }
body.ltr { direction: ltr; }

/* ── Top Bar ── */
.topbar {
    background: var(--secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

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

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.lang-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
    text-decoration: none;
}
.lang-btn:hover { background: rgba(255,255,255,0.28); }

.topbar-user {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
}

.btn-logout {
    background: rgba(192,57,43,0.7);
    border: none;
    color: #fff;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-logout:hover { background: var(--primary); }

/* ── Layout ── */
.layout { display: flex; min-height: calc(100vh - 58px); }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--card-bg);
    border-inline-end: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
}

.sidebar-section { padding: 1rem 0 0.5rem; }
.sidebar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 1.2rem 0.4rem;
}

.sidebar-nav { list-style: none; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    border-inline-start: 3px solid transparent;
    transition: all 0.15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(192,57,43,0.07);
    border-inline-start-color: var(--primary);
    color: var(--primary);
}
.sidebar-nav li a .nav-icon { width: 18px; text-align: center; flex-shrink: 0; }

.progress-circle {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--border);
    margin-inline-start: auto;
    flex-shrink: 0;
}
.progress-circle.done { background: var(--success); }
.progress-circle.partial { background: var(--warning); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 100%;
    overflow-x: hidden;
}

/* ── Cards ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    background: var(--secondary);
    color: #fff;
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    flex: 1;
}

.card-header .section-num {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 700;
}

.card-body { padding: 1.5rem; }

/* ── Form Elements ── */
.form-group { margin-bottom: 1.2rem; }

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--secondary);
}

.form-group .hint {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-style: italic;
}

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.92rem;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
    background: #fff;
}

textarea.form-control { resize: vertical; min-height: 100px; }
textarea.form-control.tall { min-height: 160px; }
textarea.form-control.short { min-height: 70px; }

/* ── Checklist Table ── */
.checklist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.checklist-table th {
    background: var(--secondary);
    color: #fff;
    padding: 0.65rem 0.75rem;
    text-align: start;
    font-weight: 600;
}
.checklist-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.checklist-table tr:nth-child(even) td { background: var(--bg); }
.checklist-table tr:hover td { background: rgba(192,57,43,0.04); }
.checklist-table input[type="text"],
.checklist-table input[type="date"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
    background: #fff;
}
.checklist-table input[type="checkbox"] {
    width: 16px; height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ── Standards Grid ── */
.standards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.standard-card {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.standard-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(192,57,43,0.12); }
.standard-card.active { border-color: var(--primary); background: rgba(192,57,43,0.05); }

.standard-card .char-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--primary);
    font-weight: 700;
    margin-bottom: 0.3rem;
}
.standard-card h4 { font-size: 0.95rem; font-weight: 700; color: var(--secondary); }
.standard-card p { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #1a252f; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.82rem; }

.btn-group { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}
.alert-danger { background: #fdf0ef; border: 1px solid #f5c6c2; color: #922b21; }
.alert-success { background: #eafaf1; border: 1px solid #a9dfbf; color: #1e8449; }
.alert-info { background: #eaf4fd; border: 1px solid #aed6f1; color: #1a5276; }
.alert-warning { background: #fef9e7; border: 1px solid #f8d89e; color: #7d6608; }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--secondary);
}
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.2rem; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab-btn {
    padding: 0.65rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Demographics Table ── */
.demo-table { width: 100%; border-collapse: collapse; }
.demo-table td { padding: 0.5rem 0.75rem; border: 1px solid var(--border); }
.demo-table td:first-child { background: var(--bg); font-weight: 600; width: 35%; color: var(--secondary); font-size: 0.88rem; }
.demo-table input { width: 100%; border: none; background: transparent; padding: 2px 0; font-size: 0.9rem; }
.demo-table input:focus { outline: none; }

/* ── Enrollment Table ── */
.enrollment-table { width: 100%; border-collapse: collapse; text-align: center; }
.enrollment-table th { background: var(--secondary); color: #fff; padding: 0.6rem; font-size: 0.85rem; }
.enrollment-table td { border: 1px solid var(--border); padding: 0.5rem; }
.enrollment-table td input { width: 100%; border: none; background: transparent; text-align: center; font-size: 0.88rem; }
.enrollment-table td:first-child { text-align: start; font-weight: 600; background: var(--bg); }

/* ── Save Indicator ── */
#save-indicator {
    position: fixed;
    bottom: 1.5rem;
    inset-inline-end: 1.5rem;
    background: var(--secondary);
    color: #fff;
    padding: 0.55rem 1rem;
    border-radius: 20px;
    font-size: 0.82rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 999;
    pointer-events: none;
}
#save-indicator.show { opacity: 1; }
#save-indicator.saved { background: var(--success); }
#save-indicator.error { background: var(--primary); }

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, #1a252f 100%);
    padding: 1rem;
}

.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}
.login-logo .logo-circle {
    width: 68px; height: 68px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    font-weight: 900;
    margin-bottom: 0.8rem;
}
.login-logo h2 { font-size: 1.15rem; font-weight: 800; color: var(--secondary); }
.login-logo p { font-size: 0.83rem; color: var(--text-muted); margin-top: 0.2rem; }

.login-form .form-control {
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
}
.login-form .btn-primary { width: 100%; justify-content: center; padding: 0.75rem; font-size: 1rem; margin-top: 0.5rem; }

/* ── Dashboard stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.stat-card .stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; margin-top: 0.25rem; }

/* ── Progress Bar ── */
.progress-bar { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 20px; transition: width 0.5s; }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { background: var(--secondary); color: #fff; padding: 0.7rem 0.9rem; text-align: start; font-weight: 600; }
.data-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: rgba(192,57,43,0.04); }

/* ── Badge ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.76rem; font-weight: 700; }
.badge-draft { background: #eee; color: #555; }
.badge-submitted { background: #d4efdf; color: #1e8449; }
.badge-reviewed { background: #d6eaf8; color: #1a5276; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ── Upload Widget ── */
.upload-widget { margin-top: 1.2rem; }
.upload-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; letter-spacing: 0.02em; }
.upload-drop-area {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 1.1rem 1rem;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    transition: border-color 0.2s, background 0.2s;
    user-select: none;
}
.upload-drop-area:hover, .upload-drop-area.dragover {
    border-color: var(--primary);
    background: rgba(52, 152, 219, 0.05);
}
.upload-drop-area span { color: var(--text); font-size: 0.9rem; }
.upload-drop-area small { color: var(--text-muted); font-size: 0.74rem; }
.upload-file-list { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.8rem; }
.upload-file-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    background: var(--bg);
}
.upload-file-card.uploading { opacity: 0.7; }
.upload-file-card.error { border-color: #e74c3c; }
.file-preview { flex-shrink: 0; max-width: 240px; min-width: 40px; }
.file-type-icon { font-size: 2.2rem; display: block; line-height: 1; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; overflow: hidden; }
.file-name-link { font-size: 0.84rem; color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.file-name-link:hover { text-decoration: underline; }
.file-size-label { font-size: 0.74rem; color: var(--text-muted); }
.file-progress { width: 100%; height: 5px; background: var(--border); border-radius: 3px; margin-top: 0.2rem; }
.file-progress-bar { height: 100%; background: var(--primary); border-radius: 3px; width: 0; transition: width 0.2s; }
.delete-file-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.05rem;
    padding: 0.25rem 0.4rem;
    border-radius: 5px;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
}
.delete-file-btn:hover { opacity: 1; background: rgba(231, 76, 60, 0.1); }

/* ── Print styles ── */
@media print {
    .topbar, .sidebar, .btn, .btn-group, #save-indicator, .no-print { display: none !important; }
    .upload-drop-area { display: none !important; }
    .delete-file-btn { display: none !important; }
    .upload-file-card { border: none; padding: 0.25rem 0; }
    .layout { display: block; }
    .main-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
    .card-header { background: #2c3e50 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { font-size: 12px; }
    .form-control { border: 1px solid #ccc; background: #fff; }
    textarea.form-control { min-height: 60px; }
    @page { margin: 1.5cm; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { padding: 1rem; }
    .standards-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
