/**
 * LOYER UI — تصميم كامل جديد (مكاتب المحاماة)
 * يستبدل الثيم القديم بالكامل
 */

:root {
    --lx-sidebar: #111827;
    --lx-sidebar-hover: #1f2937;
    --lx-sidebar-active: #1e3a5f;
    --lx-accent: #c9a227;
    --lx-accent-soft: rgba(201, 162, 39, 0.15);
    --lx-bg: #f4f5f7;
    --lx-surface: #ffffff;
    --lx-border: #e5e7eb;
    --lx-text: #111827;
    --lx-muted: #6b7280;
    --lx-header-h: 60px;
    --lx-sidebar-w: 272px;
    --lx-radius: 10px;
    --lx-font: 'Cairo', system-ui, sans-serif;
    --lx-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ——— أساس ——— */
body.loyer-app {
    margin: 0;
    min-height: 100vh;
    font-family: var(--lx-font);
    font-size: 0.9rem;
    color: var(--lx-text);
    background: var(--lx-bg);
    -webkit-font-smoothing: antialiased;
}

body.loyer-app .container-fluid {
    max-width: 100%;
    padding: 0;
}

body.loyer-app .loyer-app-shell {
    display: flex;
    flex-wrap: nowrap;
    min-height: calc(100vh - var(--lx-header-h));
    padding: 0;
    margin: 0;
}

body.loyer-app .loyer-app-shell > .row {
    display: flex;
    flex: 1;
    width: 100%;
    margin: 0;
}

body.loyer-app .loyer-sidebar-col {
    flex: 0 0 var(--lx-sidebar-w);
    width: var(--lx-sidebar-w);
    max-width: var(--lx-sidebar-w);
    padding: 0 !important;
    background: var(--lx-sidebar);
    min-height: calc(100vh - var(--lx-header-h));
    position: sticky;
    top: var(--lx-header-h);
    align-self: flex-start;
}

body.loyer-app .loyer-main-col {
    flex: 1;
    min-width: 0;
    padding: 1.25rem 1.5rem 2rem !important;
    background: var(--lx-bg);
}

body.loyer-app .loyer-main-col .main-content {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    min-height: auto;
}

/* ——— شريط علوي ——— */
.loyer-topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    padding: 0;
    margin: 0;
    background: var(--lx-surface);
    border-bottom: 1px solid var(--lx-border);
    box-shadow: var(--lx-shadow);
}

.loyer-navbar,
.navbar.loyer-navbar,
.navbar.navbar-dark {
    background: var(--lx-surface) !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: var(--lx-header-h);
    padding: 0 1.25rem;
}

.loyer-brand,
.navbar-brand {
    color: var(--lx-text) !important;
}

.loyer-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--lx-sidebar);
    color: var(--lx-accent);
    border: none;
    font-size: 1rem;
}

.loyer-brand-name {
    color: var(--lx-text) !important;
    font-size: 0.95rem;
    font-weight: 700;
}

.loyer-brand-sub {
    color: var(--lx-muted) !important;
    font-size: 0.7rem;
}

.loyer-topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--lx-bg);
    border: 1px solid var(--lx-border);
    color: var(--lx-muted);
}

.loyer-topbar-btn:hover {
    background: var(--lx-accent-soft);
    color: var(--lx-sidebar);
    border-color: var(--lx-accent);
}

.loyer-user-chip {
    background: var(--lx-bg);
    border: 1px solid var(--lx-border);
    color: var(--lx-text);
}

.loyer-user-chip::after {
    filter: none;
}

.loyer-user-avatar {
    background: var(--lx-sidebar);
    color: var(--lx-accent);
    font-weight: 700;
}

.loyer-user-name {
    color: var(--lx-text);
}

.loyer-user-role {
    color: var(--lx-muted);
}

/* ——— قائمة جانبية (شريط داكن) ——— */
.sidebar,
.loyer-sidebar {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0.85rem 0.65rem 1.25rem;
    position: static;
    max-height: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-inline-end: 2px;
}

.sidebar-section {
    margin-bottom: 0.35rem;
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-brand {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.35rem 0.5rem 1rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: start;
}

.sidebar-brand-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--lx-accent);
    border-radius: 10px;
    font-size: 1.1rem;
}

.sidebar-brand-text {
    flex: 1;
    min-width: 0;
}

.sidebar-brand-title {
    display: block;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.35;
    word-wrap: break-word;
}

.sidebar-brand-tagline,
.sidebar-brand-tag {
    display: block;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.65rem;
    margin-top: 0.15rem;
    line-height: 1.3;
}

.sidebar-section-label {
    display: block;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.65rem 0.5rem 0.3rem;
    margin: 0;
}

a.sidebar-link,
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 38px;
    padding: 0.45rem 0.55rem;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    margin: 0;
    border: none;
    text-decoration: none;
    line-height: 1.3;
    position: relative;
}

.sidebar-link-icon,
.sidebar .nav-link i {
    flex-shrink: 0;
    width: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.9rem;
}

.sidebar-link-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

a.sidebar-link:hover,
.sidebar .nav-link:hover {
    background: var(--lx-sidebar-hover);
    color: #fff;
    transform: none;
}

a.sidebar-link.active,
.sidebar .nav-link.active {
    background: var(--lx-sidebar-active);
    color: #fff;
    box-shadow: none;
    border-inline-end: 3px solid var(--lx-accent);
}

a.sidebar-link.active .sidebar-link-icon,
.sidebar .nav-link.active i {
    color: var(--lx-accent);
}

.sidebar-badge,
.sidebar .badge {
    flex-shrink: 0;
    margin-inline-start: auto;
    min-width: 1.25rem;
    padding: 0.12rem 0.38rem;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.25;
    border-radius: 6px;
    background: var(--lx-accent-soft) !important;
    color: var(--lx-accent) !important;
    position: static;
}

.sidebar-badge-accent {
    background: #dc2626 !important;
    color: #fff !important;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: 1rem;
    padding-top: 1rem;
}

.sidebar-footer-title {
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-footer-row {
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-footer-row strong {
    color: #fff;
}

/* ——— رأس الصفحة ——— */
.welcome-banner,
.loyer-page-header {
    background: var(--lx-surface);
    color: var(--lx-text);
    border: 1px solid var(--lx-border);
    border-inline-start: 4px solid var(--lx-accent);
    border-radius: var(--lx-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--lx-shadow);
}

.welcome-banner::before,
.welcome-banner::after,
.loyer-page-header::before {
    display: none;
}

.welcome-banner h1,
.loyer-page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--lx-text);
}

.welcome-banner p,
.loyer-page-header p {
    color: var(--lx-muted);
    opacity: 1;
}

/* ——— إحصائيات ——— */
.stats-grid,
.loyer-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 1199px) {
    .stats-grid,
    .loyer-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575px) {
    .stats-grid,
    .loyer-stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    background: var(--lx-surface);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--lx-shadow);
    color: var(--lx-text);
}

.stat-card::before {
    display: none !important;
}

.stat-card:hover {
    transform: none;
    border-color: #d1d5db;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--lx-bg) !important;
    color: var(--lx-sidebar) !important;
    border: 1px solid var(--lx-border) !important;
    font-size: 1rem;
}

.stat-content h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--lx-text) !important;
}

.stat-content p {
    color: var(--lx-muted) !important;
    font-size: 0.78rem;
}

/* بطاقات KPI صغيرة */
.loyer-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.loyer-kpi {
    background: var(--lx-surface);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius);
    padding: 0.85rem 1rem;
    text-align: center;
}

.loyer-kpi strong {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--lx-text);
    line-height: 1.2;
}

.loyer-kpi span {
    font-size: 0.75rem;
    color: var(--lx-muted);
}

.loyer-kpi--danger strong { color: #dc2626; }
.loyer-kpi--warn strong { color: #d97706; }
.loyer-kpi--ok strong { color: #059669; }

/* ——— بطاقات المحتوى ——— */
.content-card,
.loyer-card {
    background: var(--lx-surface);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1rem;
    box-shadow: var(--lx-shadow);
}

.content-card:hover {
    transform: none;
    box-shadow: var(--lx-shadow);
}

.content-card h3,
.loyer-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--lx-text);
    border-bottom: 1px solid var(--lx-border);
    padding-bottom: 0.65rem;
    margin-bottom: 1rem;
}

.content-card h3 i,
.loyer-card-title i {
    color: var(--lx-accent);
}

/* ——— جداول ——— */
.table,
.loyer-data-table {
    font-size: 0.85rem;
    border-collapse: collapse;
}

.table thead th,
.loyer-data-table thead th {
    background: #f9fafb !important;
    color: var(--lx-muted) !important;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 2px solid var(--lx-border) !important;
    padding: 0.7rem 0.75rem;
    border-radius: 0 !important;
}

.table tbody td,
.loyer-data-table tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: var(--lx-text);
}

.table tbody tr:hover,
.loyer-data-table tbody tr:hover {
    background: #f9fafb !important;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background: transparent;
}

.loyer-table-card .table-responsive {
    border: 1px solid var(--lx-border);
    border-radius: 8px;
    overflow: hidden;
}

/* ——— أزرار ——— */
.btn {
    font-weight: 600;
    font-size: 0.84rem;
    border-radius: 8px;
    padding: 0.45rem 0.9rem;
}

.btn-primary {
    background: var(--lx-sidebar);
    border-color: var(--lx-sidebar);
}

.btn-primary:hover {
    background: #1f2937;
    border-color: #1f2937;
}

.btn-success {
    background: #059669;
    border-color: #059669;
}

.btn-outline-primary {
    color: var(--lx-sidebar);
    border-color: var(--lx-border);
}

.btn-outline-primary:hover {
    background: var(--lx-sidebar);
    border-color: var(--lx-sidebar);
    color: #fff;
}

/* ——— نماذج ——— */
.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--lx-border);
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--lx-accent);
    box-shadow: 0 0 0 3px var(--lx-accent-soft);
}

/* ——— تنبيهات ——— */
.alert {
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.loyer-flash {
    border-radius: 8px;
}

/* ——— شارات ——— */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
}

/* إخفاء عناصر قديمة */
.product-card {
    display: none !important;
}

/* قديم: col padding */
body.loyer-app .col-md-3,
body.loyer-app .col-md-9,
body.loyer-app .col-lg-2,
body.loyer-app .col-lg-10 {
    padding: 0;
}

/* صفحات بدون هيكل app-shell */
body.loyer-app > .container-fluid:not(.loyer-app-shell) {
    padding: 1rem 1.25rem;
}

body.loyer-app > .container-fluid:not(.loyer-app-shell) .loyer-sidebar-col {
    padding: 0 !important;
}

body.loyer-app > .container-fluid:not(.loyer-app-shell) .main-content {
    background: var(--lx-surface);
    border: 1px solid var(--lx-border);
    border-radius: var(--lx-radius);
    padding: 1.25rem;
    margin-top: 0;
}

@media (max-width: 991.98px) {
    body.loyer-app .loyer-sidebar-col {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        min-height: auto;
        position: relative;
        top: 0;
    }

    body.loyer-app .loyer-app-shell {
        flex-direction: column;
    }
}
