/* ============================================
   Cabinet Notarial BRLHAJ - Styles principaux
   Design: Élégant, professionnel, sobre
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Palette - Vert foncé notarial + or */
    --primary:       #1A3C2E;
    --primary-light: #2D5C46;
    --primary-dark:  #0F2419;
    --accent:        #C9A84C;
    --accent-light:  #E8C87A;
    --bg:            #F7F5F0;
    --bg-white:      #FFFFFF;
    --sidebar-bg:    #1A3C2E;
    --text-dark:     #1C1C1C;
    --text-mid:      #4A4A4A;
    --text-light:    #8A8A8A;
    --border:        #E2DDD5;
    --success:       #2E7D32;
    --warning:       #E65100;
    --danger:        #C62828;
    --info:          #1565C0;

    /* Typography */
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body:    'Inter', sans-serif;

    /* Spacing */
    --sidebar-w:    260px;
    --header-h:     64px;
    --radius:       8px;
    --radius-lg:    14px;
    --shadow:       0 2px 12px rgba(26,60,46,0.10);
    --shadow-lg:    0 8px 32px rgba(26,60,46,0.16);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.6;
}

body.rtl {
    direction: rtl;
    text-align: right;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at center, rgba(201,168,76,0.08) 0%, transparent 60%);
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .seal {
    width: 72px;
    height: 72px;
    background: var(--primary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    border: 3px solid var(--accent);
}

.login-logo .seal svg {
    width: 36px;
    height: 36px;
    fill: var(--accent);
}

.login-logo h1 {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--primary);
    font-weight: 600;
    line-height: 1.3;
}

.login-logo p {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-dark);
    background: var(--bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,60,46,0.10);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

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

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

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

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-mid);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}

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

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
}

.alert-error { background: #FFF3F3; border-left: 4px solid var(--danger); color: var(--danger); }
.alert-success { background: #F0FFF4; border-left: 4px solid var(--success); color: var(--success); }
.alert-info { background: #EEF4FF; border-left: 4px solid var(--info); color: var(--info); }

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}

body.rtl .sidebar {
    left: auto;
    right: 0;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.sidebar-logo .seal-mini {
    width: 48px;
    height: 48px;
    background: rgba(201,168,76,0.15);
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.sidebar-logo .seal-mini svg {
    width: 22px;
    height: 22px;
    fill: var(--accent);
}

.sidebar-logo h2 {
    font-family: var(--font-display);
    font-size: 15px;
    color: #fff;
    font-weight: 600;
    line-height: 1.3;
}

.sidebar-logo p {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
}

.nav-section {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.30);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.70);
    text-decoration: none;
    font-size: 13.5px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

body.rtl .nav-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.nav-item.active {
    background: rgba(201,168,76,0.12);
    color: var(--accent);
    border-left-color: var(--accent);
}

body.rtl .nav-item.active {
    border-left-color: transparent;
    border-right-color: var(--accent);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: #fff;
}

.user-role {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    text-transform: capitalize;
}

.lang-switcher {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.lang-btn {
    flex: 1;
    padding: 5px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 4px;
    color: rgba(255,255,255,0.55);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
}

.lang-btn:hover, .lang-btn.active {
    background: var(--accent);
    color: var(--primary-dark);
    border-color: var(--accent);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.45);
    font-size: 13px;
    text-decoration: none;
    padding: 6px 0;
    transition: color 0.2s;
}

.logout-btn:hover { color: #fff; }

.logout-btn svg {
    width: 16px;
    height: 16px;
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.rtl .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-w);
}

/* TOPBAR */
.topbar {
    background: var(--bg-white);
    height: var(--header-h);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.topbar-title {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--primary);
    font-weight: 600;
}

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

/* PAGE CONTENT */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ============================================
   STATS CARDS (DASHBOARD)
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    border-top: 4px solid transparent;
    transition: box-shadow 0.2s, transform 0.2s;
}

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

.stat-card.green  { border-top-color: var(--success); }
.stat-card.gold   { border-top-color: var(--accent); }
.stat-card.red    { border-top-color: var(--danger); }
.stat-card.blue   { border-top-color: var(--info); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.green  { background: #E8F5E9; }
.stat-icon.gold   { background: #FFF8E8; }
.stat-icon.red    { background: #FFEBEE; }
.stat-icon.blue   { background: #E3F2FD; }

.stat-icon svg {
    width: 26px;
    height: 26px;
}

.stat-icon.green svg  { stroke: var(--success); }
.stat-icon.gold svg   { stroke: var(--accent); }
.stat-icon.red svg    { stroke: var(--danger); }
.stat-icon.blue svg   { stroke: var(--info); }

.stat-info {}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
    font-family: var(--font-display);
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

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

.chart-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.chart-title {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ============================================
   TABLE
   ============================================ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-title {
    font-family: var(--font-display);
    font-size: 17px;
    color: var(--primary);
    font-weight: 600;
}

.card-body {
    padding: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    background: var(--bg);
    color: var(--text-light);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

body.rtl .data-table th {
    text-align: right;
}

.data-table td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-dark);
    vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(26,60,46,0.025); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-green  { background: #E8F5E9; color: var(--success); }
.badge-gold   { background: #FFF8E8; color: #B8860B; }
.badge-red    { background: #FFEBEE; color: var(--danger); }
.badge-blue   { background: #E3F2FD; color: var(--info); }
.badge-gray   { background: #F5F5F5; color: #666; }

/* ============================================
   FORM PAGE
   ============================================ */
.form-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    max-width: 700px;
}

.form-card-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--border);
}

.form-card-header h2 {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--primary);
    font-weight: 600;
}

.form-card-body {
    padding: 28px;
}

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

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

.client-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.type-option {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.type-option:hover { border-color: var(--primary); }

.type-option.selected {
    border-color: var(--primary);
    background: rgba(26,60,46,0.04);
}

.type-option svg {
    width: 32px;
    height: 32px;
    stroke: var(--text-light);
    margin-bottom: 8px;
}

.type-option.selected svg { stroke: var(--primary); }

.type-option span {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
}

.type-option.selected span { color: var(--primary); }

/* ============================================
   SEARCH & FILTERS
   ============================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

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

.search-input svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-light);
}

body.rtl .search-input svg {
    left: auto;
    right: 12px;
}

.search-input input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}

body.rtl .search-input input {
    padding: 9px 36px 9px 12px;
}

.search-input input:focus { border-color: var(--primary); }

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

.page-btn {
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-mid);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.page-btn:hover, .page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    body.rtl .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    body.rtl .main-content { margin-right: 0; }
    .charts-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 16px; }
}

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

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-title {
    font-family: var(--font-display);
    font-size: 17px;
    color: var(--primary);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 22px;
    line-height: 1;
    padding: 0;
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(26,60,46,0.2); border-radius: 3px; }
