/* =========================================================
   KASSIM VIANDES — Crystal Glassmorphism Design System
   Colors are driven by CSS variables set inline by PHP from
   the company's logo-derived palette (see helpers/ColorExtractor).
   ========================================================= */

:root {
    --primary: #e11d2e;
    --primary-light: #ff5a63;
    --primary-dark: #a20f1d;
    --secondary: #111111;
    --accent: #f59e0b;

    --background: #f5f7fb;
    --surface: rgba(255, 255, 255, 0.65);
    --surface-strong: rgba(255, 255, 255, 0.85);

    --text: #1a1a1a;
    --muted: #6b7280;

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --shadow-soft: 0 20px 50px rgba(0, 0, 0, .08);
    --shadow-strong: 0 25px 60px rgba(0, 0, 0, .18);

    color-scheme: light;
}

[data-theme="dark"] {
    --background: #0b0d12;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-strong: rgba(255, 255, 255, 0.1);
    --text: #f2f2f5;
    --muted: #9aa0ac;
    --shadow-soft: 0 20px 50px rgba(0, 0, 0, .5);
    --shadow-strong: 0 25px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--background);
    color: var(--text);
    font-family: 'Cairo', 'Tajawal', 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body[dir="rtl"] { direction: rtl; }
body[dir="ltr"] { direction: ltr; }

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

/* ---------- Animated background ---------- */
.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(135deg, var(--background) 0%, color-mix(in srgb, var(--primary) 6%, var(--background)) 100%);
}

.background-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .35;
    animation: floatOrb 14s ease-in-out infinite;
    will-change: transform;
}
.orb-1 { width: 420px; height: 420px; background: var(--primary); top: -120px; left: -100px; animation-delay: 0s; }
.orb-2 { width: 360px; height: 360px; background: var(--accent); bottom: -100px; right: -80px; animation-delay: 3s; }
.orb-3 { width: 300px; height: 300px; background: var(--secondary); top: 40%; left: 60%; animation-delay: 6s; opacity: .18; }

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -40px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    .background-orb { animation: none; }
}

/* ---------- Glass primitives ---------- */
.glass-card {
    background: var(--surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
[data-theme="dark"] .glass-card { border-color: rgba(255, 255, 255, .08); }

.glass-navbar {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, .3);
}

.glass-sidebar {
    background: var(--surface-strong);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-inline-end: 1px solid rgba(255, 255, 255, .25);
}

.glass-modal {
    background: var(--surface-strong);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-strong);
}

.glass-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: rgba(255, 255, 255, .5);
    border: 1px solid rgba(255, 255, 255, .4);
}
.glass-badge.new { color: #fff; background: var(--primary); border-color: var(--primary); }
.glass-badge.processing { color: #92400e; background: rgba(245, 158, 11, .18); border-color: rgba(245,158,11,.4); }
.glass-badge.resolved { color: #065f46; background: rgba(34, 197, 94, .18); border-color: rgba(34,197,94,.4); }
.glass-badge.closed { color: var(--muted); background: rgba(107, 114, 128, .15); }

.glass-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}
.glass-table th {
    text-align: start;
    font-size: .8rem;
    color: var(--muted);
    padding: 0 16px 6px;
    font-weight: 600;
}
.glass-table td {
    background: var(--surface);
    padding: 14px 16px;
    font-size: .92rem;
}
.glass-table tr td:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.glass-table tr td:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }

.glass-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    padding: 13px 26px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 700;
    font-size: .95rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 10px 30px color-mix(in srgb, var(--primary) 45%, transparent);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.glass-button:hover { transform: translateY(-2px) scale(1.015); filter: brightness(1.05); box-shadow: 0 16px 36px color-mix(in srgb, var(--primary) 55%, transparent); }
.glass-button:active { transform: translateY(0) scale(.98); }
.glass-button:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.glass-button.secondary {
    background: rgba(255, 255, 255, .5);
    color: var(--text);
    box-shadow: none;
    border: 1px solid rgba(0,0,0,.08);
}
.glass-button.ghost {
    background: transparent;
    color: var(--primary);
    box-shadow: none;
    padding: 10px 16px;
}
.glass-button.sm { padding: 8px 16px; font-size: .82rem; }

.glass-input, .glass-select, .glass-textarea {
    width: 100%;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid rgba(0,0,0,.08);
    background: rgba(255,255,255,.55);
    font-family: inherit;
    font-size: .95rem;
    color: var(--text);
    transition: border-color .2s ease, box-shadow .2s ease, transform .15s ease;
}
[data-theme="dark"] .glass-input,
[data-theme="dark"] .glass-select,
[data-theme="dark"] .glass-textarea { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); color: var(--text); }

.glass-input:focus, .glass-select:focus, .glass-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
.glass-textarea { resize: vertical; min-height: 110px; }

.field-label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--muted);
}

/* ---------- Utility ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.muted { color: var(--muted); }
.mt-8{margin-top:8px}.mt-16{margin-top:16px}.mt-24{margin-top:24px}.mt-32{margin-top:32px}
.mb-8{margin-bottom:8px}.mb-16{margin-bottom:16px}.mb-24{margin-bottom:24px}

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes staggerIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes checkDraw { from { stroke-dashoffset: 60; } to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.anim-fade-in { animation: fadeIn .5s ease both; }
.anim-slide-up { animation: slideUp .55s cubic-bezier(.2,.8,.2,1) both; }
.anim-pop-in { animation: popIn .4s cubic-bezier(.2,.8,.2,1) both; }
.stagger > * { animation: staggerIn .45s ease both; }
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .12s; }
.stagger > *:nth-child(3) { animation-delay: .19s; }
.stagger > *:nth-child(4) { animation-delay: .26s; }
.stagger > *:nth-child(5) { animation-delay: .33s; }
.stagger > *:nth-child(6) { animation-delay: .40s; }

.spinner {
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* Responsive helpers */
@media (max-width: 720px) {
    .hide-mobile { display: none !important; }
}
@media (min-width: 721px) {
    .hide-desktop { display: none !important; }
}
.table-scroll { overflow-x: auto; }
