/* ===========================================
   Alarab Law Firm Management System
   Color scheme matches the website (gold/black)
   =========================================== */

:root {
    --gold: #c9a961;
    --gold-light: #e2c989;
    --gold-dark: #a8893e;
    --black: #0a0a0a;
    --dark: #1a1a1a;
    --darker: #050505;
    --gray: #2a2a2a;
    --gray-light: #3a3a3a;
    --light-gray: #b0b0b0;
    --white: #ffffff;
    --green: #25D366;
    --green-dark: #128C7E;
    --red: #e74c3c;
    --red-dark: #c0392b;
    --blue: #3498db;
    --yellow: #f39c12;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s ease;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

html, body {
    font-family: 'Tajawal', -apple-system, sans-serif;
    background: var(--darker);
    color: var(--white);
    min-height: 100vh;
    direction: rtl;
}

body { overflow-x: hidden; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, select, textarea, button {
    font-family: inherit;
}

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

/* ===== Login Screen ===== */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--darker) 0%, var(--dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.login-card {
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-logo img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    margin-bottom: 15px;
    filter: drop-shadow(0 4px 12px rgba(201, 169, 97, 0.3));
}

.login-card h1 {
    color: var(--gold);
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.login-card > p {
    color: var(--light-gray);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.login-card .form-group { text-align: right; margin-bottom: 16px; }

.login-hint {
    margin-top: 20px;
    color: var(--light-gray);
    font-size: 0.85rem;
}

/* ===== App Shell ===== */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-areas: "sidebar topbar" "sidebar main";
    min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
    grid-area: topbar;
    background: var(--dark);
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    color: var(--white);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.menu-toggle:hover { background: var(--gray); }

.topbar-brand { display: flex; align-items: center; gap: 12px; flex: 1; }

.topbar-logo {
    width: 38px; height: 38px;
    object-fit: contain;
    border-radius: 50%;
    background: var(--gray);
    padding: 3px;
}

.topbar-title { font-weight: 800; color: var(--gold); font-size: 1rem; }
.topbar-sub { font-size: 0.75rem; color: var(--light-gray); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--gray);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all var(--transition);
}

.icon-btn:hover { background: var(--gray-light); color: var(--gold); }

.icon-btn .badge {
    position: absolute;
    top: -3px;
    left: -3px;
    background: var(--red);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.user-menu { position: relative; }

.user-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    background: var(--gray);
    border-radius: 24px;
    color: var(--white);
    transition: all var(--transition);
    font-size: 0.9rem;
}

.user-btn:hover { background: var(--gray-light); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: var(--radius-sm);
    min-width: 180px;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: none;
    z-index: 100;
}

.user-dropdown.open { display: block; }

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--white);
    transition: background var(--transition);
    font-size: 0.9rem;
}

.user-dropdown a:hover { background: var(--gray-light); color: var(--gold); }

/* ===== Sidebar ===== */
.sidebar {
    grid-area: sidebar;
    background: var(--dark);
    border-left: 1px solid rgba(201, 169, 97, 0.1);
    padding: 20px 0;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--light-gray);
    transition: all var(--transition);
    font-weight: 500;
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(201, 169, 97, 0.08);
    color: var(--white);
}

.nav-item.active {
    background: rgba(201, 169, 97, 0.12);
    color: var(--gold);
    border-right-color: var(--gold);
}

.nav-item i { width: 20px; text-align: center; font-size: 1.05rem; }

/* ===== Main Content ===== */
.main {
    grid-area: main;
    padding: 30px;
    overflow-x: hidden;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--white);
}

.page-title small {
    display: block;
    font-size: 0.85rem;
    color: var(--light-gray);
    font-weight: 400;
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92rem;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--black);
}

.btn-primary:hover { box-shadow: 0 6px 18px rgba(201, 169, 97, 0.4); }

.btn-secondary {
    background: var(--gray);
    color: var(--white);
    border: 1px solid rgba(201, 169, 97, 0.2);
}

.btn-secondary:hover { background: var(--gray-light); border-color: var(--gold); }

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

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

.btn-block { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    border-radius: 6px;
}

/* ===== Cards ===== */
.card {
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.1);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.1);
}

.card-title { color: var(--gold); font-weight: 700; font-size: 1.05rem; }

/* ===== Stat Cards (Dashboard) ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.15);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
    border-color: var(--gold);
}

.stat-icon {
    width: 55px; height: 55px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.green { background: linear-gradient(135deg, #25D366, #128C7E); color: var(--white); }
.stat-icon.red { background: linear-gradient(135deg, #e74c3c, #c0392b); color: var(--white); }
.stat-icon.blue { background: linear-gradient(135deg, #3498db, #2980b9); color: var(--white); }
.stat-icon.yellow { background: linear-gradient(135deg, #f39c12, #e67e22); color: var(--white); }

.stat-info { flex: 1; }
.stat-info .num { font-size: 1.7rem; font-weight: 900; color: var(--white); }
.stat-info .label { font-size: 0.85rem; color: var(--light-gray); }

/* ===== Tables ===== */
.table-wrap {
    background: var(--gray);
    border-radius: var(--radius);
    border: 1px solid rgba(201, 169, 97, 0.1);
    overflow: hidden;
}

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

th {
    background: var(--darker);
    color: var(--gold);
    text-align: right;
    padding: 14px 16px;
    font-weight: 700;
    font-size: 0.88rem;
    border-bottom: 2px solid rgba(201, 169, 97, 0.2);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--white);
    font-size: 0.9rem;
}

tr:hover td { background: rgba(201, 169, 97, 0.04); }

td .actions { display: flex; gap: 6px; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    color: var(--light-gray);
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--darker);
    border: 1px solid rgba(201, 169, 97, 0.15);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 0.95rem;
    transition: border-color var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.form-group textarea { min-height: 100px; resize: vertical; }

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

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

/* ===== Search + Filters bar ===== */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--light-gray);
}

.search-box input { padding-right: 40px; }

/* ===== Status badges ===== */
.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
}

.status.active, .status.paid, .status.open { background: rgba(46, 204, 113, 0.18); color: #2ecc71; }
.status.pending, .status.partial, .status.draft { background: rgba(243, 156, 18, 0.18); color: #f39c12; }
.status.closed, .status.sent { background: rgba(52, 152, 219, 0.18); color: #3498db; }
.status.cancelled, .status.overdue { background: rgba(231, 76, 60, 0.18); color: #e74c3c; }

/* ===== Modal ===== */
.modal-container {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal {
    position: relative;
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 400px; }
.modal.modal-confirm { max-width: 420px; text-align: center; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
}

.modal-header h3 { color: var(--gold); font-size: 1.15rem; }

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 22px;
    border-top: 1px solid rgba(201, 169, 97, 0.15);
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    color: var(--white);
    box-shadow: var(--shadow);
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--yellow); }

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

/* ===== Empty state ===== */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--light-gray);
}

.empty i { font-size: 3rem; color: var(--gray-light); margin-bottom: 15px; }

.empty h3 { color: var(--white); margin-bottom: 8px; }

/* ===== Detail view ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.detail-item { padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.detail-item .lbl { color: var(--light-gray); font-size: 0.82rem; }
.detail-item .val { color: var(--white); font-size: 0.95rem; font-weight: 500; margin-top: 3px; }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 10px 18px;
    color: var(--light-gray);
    background: none;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab:hover { color: var(--white); }

.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ===== Charts container ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card {
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.1);
    border-radius: var(--radius);
    padding: 20px;
    min-height: 300px;
}

.chart-card h3 { color: var(--gold); margin-bottom: 15px; font-size: 1rem; }

.chart-card canvas { max-height: 280px; }

/* ===== Document list ===== */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

.doc-card {
    background: var(--darker);
    border: 1px solid rgba(201, 169, 97, 0.1);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}

.doc-card:hover { border-color: var(--gold); transform: translateY(-2px); }

.doc-card i { font-size: 2.5rem; color: var(--gold); margin-bottom: 10px; }

.doc-card .name { font-weight: 600; word-break: break-all; font-size: 0.9rem; }
.doc-card .meta { font-size: 0.75rem; color: var(--light-gray); margin-top: 5px; }

/* ===== Calendar/Schedule view ===== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeline-item {
    background: var(--darker);
    border: 1px solid rgba(201, 169, 97, 0.1);
    border-right: 4px solid var(--gold);
    border-radius: var(--radius-sm);
    padding: 15px 18px;
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 15px;
    align-items: center;
    transition: all var(--transition);
}

.timeline-item:hover { border-color: var(--gold); }

.timeline-date {
    text-align: center;
    background: var(--gray);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.timeline-date .day { font-size: 1.4rem; font-weight: 900; color: var(--gold); }
.timeline-date .month { font-size: 0.75rem; color: var(--light-gray); }
.timeline-date .year { font-size: 0.7rem; color: var(--light-gray); }

.timeline-content .title { font-weight: 700; color: var(--white); }
.timeline-content .sub { color: var(--light-gray); font-size: 0.85rem; margin-top: 4px; }

.timeline-item.urgent { border-right-color: var(--red); }
.timeline-item.upcoming { border-right-color: var(--yellow); }
.timeline-item.passed { opacity: 0.6; border-right-color: var(--gray-light); }

/* ===== Report cards ===== */
.report-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.report-row .lbl { color: var(--light-gray); }
.report-row .val { color: var(--white); font-weight: 700; }
.report-row.total { font-size: 1.1rem; padding-top: 18px; border-top: 2px solid var(--gold); }
.report-row.total .val { color: var(--gold); }

/* ===== Login style adjustments ===== */
.login-screen .form-group { text-align: right; }
.login-screen input { background: var(--darker); }

/* ===== Responsive ===== */
@media (max-width: 968px) {
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        right: 0;
        width: var(--sidebar-width);
        height: calc(100vh - var(--topbar-height));
        z-index: 100;
        transform: translateX(100%);
        transition: transform var(--transition);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .timeline-item { grid-template-columns: 1fr; }
    .main { padding: 20px 15px; }
    .topbar-title { font-size: 0.9rem; }
    .topbar-sub { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 568px) {
    .stats-grid { grid-template-columns: 1fr; }
    .user-btn span { display: none; }
    .modal { max-height: 95vh; }
    .page-title { font-size: 1.2rem; }
}

/* ===== Misc utility ===== */
.text-gold { color: var(--gold); }
.text-success { color: #2ecc71; }
.text-danger { color: #e74c3c; }
.text-muted { color: var(--light-gray); }
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* Notifications dropdown */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--gray);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: var(--radius-sm);
    width: 340px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow);
    display: none;
    z-index: 100;
}

.notif-dropdown.open { display: block; }

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 10px;
    transition: background var(--transition);
}

.notif-item:hover { background: var(--gray-light); }

.notif-item .icon { color: var(--gold); font-size: 1.1rem; }
.notif-item .body { flex: 1; font-size: 0.88rem; }
.notif-item .time { font-size: 0.75rem; color: var(--light-gray); margin-top: 3px; }
.notif-item.unread { background: rgba(201, 169, 97, 0.05); }

/* Settings page tabs */
.settings-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 25px;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-nav a {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--light-gray);
    transition: all var(--transition);
}

.settings-nav a.active { background: rgba(201, 169, 97, 0.12); color: var(--gold); }
.settings-nav a:hover { background: rgba(201, 169, 97, 0.05); color: var(--white); }

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
}
