/* ═══════════════════════════════════════════════
   DocMarocSAAS — Reusable Components
═══════════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 22px; border: none; border-radius: var(--r);
    font-family: var(--font-body); font-size: 0.88rem; font-weight: 500;
    cursor: pointer; transition: all var(--duration) var(--ease);
    text-decoration: none; line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: var(--navy); box-shadow: var(--shadow-gold);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(200,151,58,0.35); }

.btn-secondary {
    background: var(--surface-2); color: var(--cream);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--gold); color: var(--gold-light); }

.btn-danger {
    background: var(--error-dim); color: var(--error);
    border: 1px solid rgba(231, 76, 60, 0.3);
}
.btn-danger:hover { background: rgba(231, 76, 60, 0.2); }

.btn-success {
    background: var(--success-dim); color: var(--success);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 30px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Cards ── */
.card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    backdrop-filter: blur(12px);
    transition: all var(--duration) var(--ease);
}
.card:hover { border-color: var(--gold-dim); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--font-display); font-size: 1.05rem; color: var(--cream); }
.card-subtitle { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ── Stat Cards ── */
.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    backdrop-filter: blur(12px);
    transition: all var(--duration) var(--ease);
}
.stat-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-gold); }
.stat-icon { font-size: 1.6rem; margin-bottom: 10px; color: var(--gold); }
.stat-icon svg { width: 32px; height: 32px; stroke-width: 1.5; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Form Elements ── */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px;
    font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px;
}
.form-control {
    width: 100%; padding: 11px 16px;
    background: var(--surface-2); color: var(--cream);
    border: 1px solid var(--border); border-radius: var(--r);
    font-family: var(--font-body); font-size: 0.9rem;
    transition: all var(--duration) var(--ease);
}
.form-control:focus { outline: none; border-color: var(--gold); background: var(--surface-3); box-shadow: 0 0 0 3px var(--gold-dim); }
.form-control::placeholder { color: rgba(245,240,232,0.25); }
select.form-control { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23C8973A' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
select.form-control option { background-color: var(--navy-mid, #152238); color: var(--cream, #f5f0e8); padding: 10px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-full { grid-column: 1 / -1; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }
.form-hint { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-draft     { background: var(--surface-2); color: var(--muted); }
.badge-preparation { background: var(--info-dim); color: var(--info); }
.badge-validation  { background: var(--warning-dim); color: var(--warning); }
.badge-signature   { background: rgba(155, 89, 182, 0.15); color: #9B59B6; }
.badge-finalized   { background: var(--success-dim); color: var(--success); }
.badge-archived    { background: var(--surface-2); color: rgba(245,240,232,0.3); }
.badge-admin       { background: var(--gold-dim); color: var(--gold); }
.badge-collaborator { background: var(--info-dim); color: var(--info); }
.badge-assistant   { background: var(--surface-2); color: var(--muted); }

/* ── Toast ── */
.toast {
    position: fixed; top: 20px; right: 20px;
    padding: 14px 24px; border-radius: var(--r);
    font-size: 0.88rem; font-weight: 500; z-index: 9999;
    transform: translateX(120%); transition: transform 0.3s var(--ease);
    backdrop-filter: blur(12px); max-width: 400px;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }
.toast.error   { background: var(--error-dim); color: var(--error); border: 1px solid rgba(231,76,60,0.3); }
.toast.info    { background: var(--info-dim); color: var(--info); border: 1px solid rgba(52,152,219,0.3); }

/* ── Alert ── */
.alert {
    padding: 14px 20px; border-radius: var(--r); margin-bottom: 20px;
    font-size: 0.88rem; line-height: 1.5;
}
.alert-error { background: var(--error-dim); color: var(--error); border: 1px solid rgba(231,76,60,0.3); }
.alert-success { background: var(--success-dim); color: var(--success); border: 1px solid rgba(46,204,113,0.3); }
.alert-info { background: var(--info-dim); color: var(--info); border: 1px solid rgba(52,152,219,0.3); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.table {
    width: 100%; border-collapse: collapse;
}
.table th {
    text-align: left; padding: 12px 16px;
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted); background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 12px 16px; border-bottom: 1px solid var(--border-light);
    font-size: 0.88rem; color: var(--cream);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-1); }

/* ── Empty state ── */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; color: rgba(200, 151, 58, 0.4); }
.empty-state-icon svg { width: 48px; height: 48px; stroke-width: 1.5; }
.empty-state-title { font-family: var(--font-display); font-size: 1.2rem; color: var(--cream); margin-bottom: 8px; }
.empty-state-text { font-size: 0.88rem; margin-bottom: 24px; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(7,20,42,0.85); z-index: 1000;
    display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--navy-mid); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 32px; width: 90%; max-width: 520px;
    box-shadow: var(--shadow-lg);
}
.modal-title { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 14px; border-radius: var(--r-sm);
    font-size: 0.82rem; font-weight: 500;
    border: 1px solid var(--border); color: var(--muted);
    transition: all var(--duration) var(--ease);
}
.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .active { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }

/* ── Divider ── */
.divider {
    display: flex; align-items: center; gap: 16px;
    color: var(--muted); font-size: 0.8rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px;
    margin: 28px 0 20px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Loading spinner ── */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--gold);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Workflow Steps ── */
.workflow-bar { display: flex; align-items: center; gap: 0; margin: 20px 0; }
.workflow-step {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; font-size: 0.78rem; font-weight: 500;
    color: var(--muted); position: relative;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.workflow-step.active { color: var(--gold); }
.workflow-step.done { color: var(--success); }
.workflow-step .step-dot {
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700;
    background: var(--surface-2); border: 2px solid var(--border);
}
.workflow-step.active .step-dot { background: var(--gold-dim); border-color: var(--gold); color: var(--gold); }
.workflow-step.done .step-dot { background: var(--success-dim); border-color: var(--success); color: var(--success); }
.workflow-connector {
    flex: 1; height: 2px; background: var(--border); min-width: 20px;
}
.workflow-connector.done { background: var(--success); }

/* ── Modals ── */
.modal {
    display: none; 
    position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; overflow: auto;
    background-color: rgba(10, 16, 29, 0.85); /* semi-transparent overlay */
    backdrop-filter: blur(4px);
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-content {
    background-color: var(--surface-1);
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    width: 100%; max-width: 1000px;
    max-height: 90vh; /* Don't exceed screen height */
    display: flex; flex-direction: column;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
    position: relative;
    animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes modalScaleIn {
    from { transform: scale(0.95) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.modal-header h3 { font-family: var(--font-display); font-size: 1.5rem; color: var(--cream); margin: 0; }
.close { color: var(--muted); font-size: 28px; font-weight: bold; cursor: pointer; transition: color var(--duration); line-height: 1; display: flex; align-items: center; justify-content: center;}
.close:hover, .close:focus { color: var(--gold); text-decoration: none; }
.doc-viewer { flex: 1; border-radius: 8px; border: 1px solid var(--border); overflow-y: auto; background: #fff; color: #333; padding: 40px !important; }

