/**
 * Markaz ul-Fuhum — Admin CSS
 * ============================
 * Overrides cibles pour Unfold Admin. Ne se bat PAS avec Tailwind.
 * Principe : on ne touche que ce qu'Unfold ne configure pas via COLORS/settings.
 */

@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap');

/* =============================================================
   1. VARIABLES
   ============================================================= */
:root {
    --m-gold: #B79C58;
    --m-gold-dark: #83703D;
    --m-gold-light: #D4BC7A;
    --m-blue: #4E5B77;
    --m-blue-dark: #3A4559;
    --m-dark: #1C273C;
    --m-bg: #EDE4D6;
    --m-card: #FFFBF5;
    --m-divider: #D4C4B0;
    --m-text: #1C273C;
    --m-text-secondary: #4E5B77;
    --m-error: #B71C1C;
    --m-success: #2E7D32;
}

/* =============================================================
   2. LOGIN PAGE
   ============================================================= */

body.login #page,
body.login #page.bg-white {
    background: linear-gradient(135deg, #EDE4D6 0%, #FFFBF5 40%, #EDE4D6 100%) !important;
    position: relative;
}

body.login #page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(183,156,88,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(78,91,119,0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body.login #page > .flex.flex-col.grow {
    z-index: 1;
    position: relative;
}

body.login .w-full.sm\:w-96,
body.login [class*="sm:w-96"] {
    background: rgba(255,251,245,0.95) !important;
    backdrop-filter: blur(20px);
    border-radius: 16px !important;
    padding: 2rem !important;
    box-shadow: 0 20px 60px rgba(28,39,60,0.12), 0 0 0 1px rgba(183,156,88,0.15) !important;
    border: 1px solid rgba(183,156,88,0.2) !important;
}

body.login .border-b.border-base-200 {
    border-bottom-color: var(--m-gold) !important;
    border-bottom-width: 2px !important;
    text-align: center !important;
}

body.login .text-primary-600,
body.login .text-primary-500 {
    font-family: 'Amiri', 'Scheherazade New', serif !important;
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    display: block !important;
    margin-top: 0.25rem !important;
}

.markaz-login-logo {
    text-align: center;
    margin-bottom: 0.75rem;
}

.markaz-login-logo-img {
    width: 56px !important;
    height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    object-fit: contain !important;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(183,156,88,0.25);
    border: 2px solid rgba(183,156,88,0.3);
    display: inline-block !important;
}

.markaz-login-footer {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(183,156,88,0.2);
}

.markaz-login-bismillah {
    font-family: 'Amiri', serif;
    font-size: 1rem;
    color: var(--m-gold);
    opacity: 0.7;
    direction: rtl;
}

/* Lien Return to site — ne pas heriter les styles du titre arabe */
body.login .absolute a[class*="text-primary"] {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    display: inline-flex !important;
    margin-top: 0 !important;
}

@media (max-width: 640px) {
    body.login .w-full.sm\:w-96 {
        margin: 1rem !important;
        padding: 1.5rem !important;
    }
    .markaz-login-logo-img {
        width: 44px !important;
        height: 44px !important;
        max-width: 44px !important;
        max-height: 44px !important;
    }
}

/* =============================================================
   3. LAYOUT & SIDEBAR
   ============================================================= */

body {
    background-color: var(--m-bg) !important;
}

nav[aria-label="Navigation"] a:hover {
    color: var(--m-gold) !important;
}

nav a[aria-current="page"],
nav[aria-label="Navigation"] a[class*="bg-primary"] {
    border-left: 3px solid var(--m-gold-dark) !important;
}

aside [class*="text-xs"][class*="uppercase"],
aside [class*="font-semibold"][class*="text-xs"] {
    color: var(--m-gold) !important;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

/* =============================================================
   4. TABLES
   ============================================================= */

thead th {
    background: linear-gradient(135deg, var(--m-blue) 0%, var(--m-blue-dark) 100%) !important;
    color: white !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
}

thead th a,
thead th a:link,
thead th a:visited,
thead th span {
    color: white !important;
    background-color: transparent !important;
}

thead th a:hover {
    color: var(--m-gold-light) !important;
}

thead th svg,
thead th i {
    color: white !important;
    fill: white !important;
}

tbody tr:nth-child(even) {
    background-color: rgba(78,91,119,0.03);
}

tbody tr:hover {
    background-color: rgba(183,156,88,0.08) !important;
}

/* =============================================================
   5. ACTION BUTTONS
   ============================================================= */

a.button,
.button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 5px 12px !important;
    border-radius: 6px !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    background: var(--m-dark) !important;
    color: #fff !important;
    border: none !important;
    transition: all 0.2s ease !important;
    cursor: pointer;
    line-height: 1.4 !important;
}

a.button:hover,
.button:hover {
    background: #2E3A52 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(28,39,60,0.3) !important;
    color: #fff !important;
    text-decoration: none !important;
}

a.button .material-symbols-outlined,
td .material-symbols-outlined {
    font-size: 16px !important;
    margin-right: 2px;
}

/* =============================================================
   6. FORMS (minimal — Unfold gere le reste)
   ============================================================= */

input:focus,
textarea:focus,
select:focus {
    border-color: var(--m-gold) !important;
    box-shadow: 0 0 0 3px rgba(183,156,88,0.2) !important;
    outline: none !important;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--m-gold) !important;
}

#searchbar:focus,
input[name="q"]:focus {
    border-color: var(--m-gold) !important;
    box-shadow: 0 0 0 3px rgba(183,156,88,0.15) !important;
}

.submit-row {
    border-top: 2px solid var(--m-gold) !important;
}

.submit-row .deletelink,
a.deletelink {
    background: var(--m-error) !important;
    color: white !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    text-decoration: none !important;
}

/* =============================================================
   7. REQUIRED FIELDS — Asterisque dore discret
   ============================================================= */

label span.text-red-600 {
    color: var(--m-gold) !important;
    font-size: 0.65em !important;
    font-weight: 700 !important;
    vertical-align: super !important;
    margin-left: 2px !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    display: inline !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    line-height: 1 !important;
    opacity: 0.8 !important;
}

/* =============================================================
   8. ARABIC TEXT
   ============================================================= */

.arabic-text,
[dir="rtl"] {
    font-family: 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif;
    direction: rtl;
    text-align: right;
    line-height: 1.8;
}

/* =============================================================
   9. THEME-AWARE TEXT CLASSES
   ============================================================= */

.m-link { color: #1976d2; text-decoration: none; }
.m-link:hover { color: #1565c0; text-decoration: underline; }

.m-link-sub { color: #555; text-decoration: none; }
.m-link-sub:hover { color: #333; }

.m-text-sub { color: #555; }
.m-text-muted { color: #888; font-size: 0.9em; }

/* =============================================================
   10. UTILITIES
   ============================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--m-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--m-gold-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--m-gold);
}

.messagelist .success {
    border-left: 4px solid var(--m-success) !important;
}

.messagelist .error {
    border-left: 4px solid var(--m-error) !important;
}

nav[aria-label="Breadcrumb"] a:hover {
    color: var(--m-gold) !important;
}

audio {
    width: 220px;
    max-width: 100%;
    border-radius: 6px;
}

@media print {
    header, aside, nav {
        display: none !important;
    }
    main {
        margin: 0 !important;
        padding: 20px !important;
    }
}

/* =============================================================
   11. DARK MODE — Comprehensive overrides
   ============================================================= */

/* --- Body & layout --- */
.dark body {
    background-color: #121212 !important;
}

/* --- Tables --- */
.dark thead th {
    background: linear-gradient(135deg, #3A4559 0%, #2A3344 100%) !important;
}

.dark tbody tr:nth-child(even) {
    background-color: rgba(255,255,255,0.03);
}

.dark tbody tr:hover {
    background-color: rgba(183,156,88,0.12) !important;
}

/* --- Action Buttons: gold in dark mode --- */
.dark a.button,
.dark .button {
    background: var(--m-gold) !important;
    color: var(--m-dark) !important;
    border-color: var(--m-gold) !important;
}

.dark a.button:hover,
.dark .button:hover {
    background: var(--m-gold-light) !important;
    color: var(--m-dark) !important;
    box-shadow: 0 3px 8px rgba(183,156,88,0.4) !important;
}

.dark a.button .material-symbols-outlined,
.dark .button .material-symbols-outlined {
    color: var(--m-dark) !important;
}

/* --- Theme-aware text classes: dark variants --- */
.dark .m-link { color: #64B5F6 !important; }
.dark .m-link:hover { color: #90CAF9 !important; }

.dark .m-link-sub { color: #bbb !important; }
.dark .m-link-sub:hover { color: #ddd !important; }

.dark .m-text-sub { color: #bbb !important; }
.dark .m-text-muted { color: #aaa !important; }

/* --- Forms --- */
.dark input:focus,
.dark textarea:focus,
.dark select:focus {
    border-color: var(--m-gold) !important;
    box-shadow: 0 0 0 3px rgba(183,156,88,0.3) !important;
}

.dark .submit-row {
    border-top-color: var(--m-gold-dark) !important;
}

/* --- Sidebar active link --- */
.dark nav a[aria-current="page"],
.dark nav[aria-label="Navigation"] a[class*="bg-primary"] {
    border-left-color: var(--m-gold) !important;
}

/* --- Fallback: override inline color styles via attribute selectors --- */
.dark [style*="color:#1976d2"],
.dark [style*="color: #1976d2"] {
    color: #64B5F6 !important;
}

.dark [style*="color:#555"],
.dark [style*="color: #555"] {
    color: #bbb !important;
}

.dark [style*="color:#888"],
.dark [style*="color: #888"] {
    color: #aaa !important;
}

.dark [style*="color:#666"],
.dark [style*="color: #666"] {
    color: #999 !important;
}

/* --- Corrections display (f-string with embedded styles) --- */
.dark [style*="background: #fffbe6"],
.dark [style*="background:#fffbe6"] {
    background: #2A2A1A !important;
    border-color: #554400 !important;
}

.dark [style*="background: white"],
.dark [style*="background:white"] {
    background: #1E1E1E !important;
}

.dark [style*="color: #d48806"],
.dark [style*="color:#d48806"] {
    color: #D4A017 !important;
}

.dark [style*="color: #28a745"],
.dark [style*="color:#28a745"] {
    color: #66BB6A !important;
}

/* --- Badges (corrections pending) --- */
.dark [style*="background: #ffc107"],
.dark [style*="background:#ffc107"] {
    background: var(--m-gold) !important;
    color: #000 !important;
}

/* --- Scrollbar --- */
.dark ::-webkit-scrollbar-track {
    background: #121212;
}

.dark ::-webkit-scrollbar-thumb {
    background: #555;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: var(--m-gold);
}

/* --- Messages --- */
.dark .messagelist .success {
    background-color: rgba(46,125,50,0.15) !important;
}

.dark .messagelist .error {
    background-color: rgba(183,28,28,0.15) !important;
}

/* --- Login --- */
.dark body.login #page,
.dark body.login #page.bg-white {
    background: linear-gradient(135deg, #121212 0%, #1E1E1E 40%, #121212 100%) !important;
}

.dark body.login .w-full.sm\:w-96 {
    background: rgba(30,30,30,0.95) !important;
    border-color: rgba(183,156,88,0.25) !important;
}
