/* ================================
   Mahal Timzikid - Credit Management App
   Global Styles & Configuration
   ================================ */

/* Tailwind CSS Theme Configuration */
@import url('https://cdn.tailwindcss.com?plugins=forms,container-queries');
@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&family=Cairo:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

/* Root CSS Variables - Vibrant Color Scheme */
:root {
    /* Primary Colors - Vibrant Teal/Blue */
    --primary: #0da5de;
    --primary-container: #0891b2;
    --on-primary: #ffffff;
    --on-primary-fixed: #001e2c;
    --primary-fixed: #0ea5e9;
    --primary-fixed-dim: #06b6d4;
    
    /* Secondary Colors - Vibrant Green */
    --secondary: #16a34a;
    --secondary-container: #22c55e;
    --on-secondary: #ffffff;
    --secondary-fixed: #4ade80;
    --secondary-fixed-dim: #86efac;
    --on-secondary-fixed: #00210d;
    --on-secondary-container: #00723a;
    --on-secondary-fixed-variant: #005228;
    
    /* Tertiary Colors - Vibrant Purple */
    --tertiary: #a855f7;
    --tertiary-container: #c084fc;
    --tertiary-fixed: #d8b4fe;
    --tertiary-fixed-dim: #e9d5ff;
    --on-tertiary: #ffffff;
    --on-tertiary-fixed: #3f0f6b;
    --on-tertiary-container: #fcfdfe;
    --on-tertiary-fixed-variant: #5b21b6;
    
    /* Error Colors - Vibrant Red */
    --error: #dc2626;
    --error-container: #fee2e2;
    --on-error: #ffffff;
    --on-error-container: #7f1d1d;
    
    /* Surface Colors - Gradient Background */
    --surface: #f8fafc;
    --surface-dim: #cbd5e1;
    --surface-bright: #ffffff;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f1f5f9;
    --surface-container: #e2e8f0;
    --surface-container-high: #cbd5e1;
    --surface-container-highest: #94a3b8;
    
    /* Text Colors */
    --on-surface: #0f172a;
    --on-surface-variant: #475569;
    
    /* Borders and Outlines */
    --outline: #64748b;
    --outline-variant: #cbd5e1;
    
    /* Background */
    --background: #f8fafc;
    --on-background: #0f172a;
    
    /* Inverse Colors */
    --inverse-surface: #1e293b;
    --inverse-on-surface: #f1f5f9;
    --inverse-primary: #38bdf8;
    
    --surface-tint: #0da5de;
    
    /* Accent Colors */
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --accent-yellow: #eab308;
    --accent-indigo: #6366f1;
}

/* Base Styles */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
    background-color: var(--background);
    color: var(--on-background);
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
.font-headline-lg-mobile {
    font-size: 20px;
    font-weight: 700;
    line-height: 28px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-headline-lg {
    font-size: 24px;
    font-weight: 700;
    line-height: 32px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-headline-md {
    font-size: 20px;
    font-weight: 600;
    line-height: 28px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-body-lg {
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-body-md {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-label-lg {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

.font-label-sm {
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    font-family: 'Cairo', 'Be Vietnam Pro', sans-serif;
}

/* Material Icons */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    width: 1em;
    min-width: 1em;
    height: 1em;
    overflow: hidden;
    color: transparent;
}

.icons-ready .material-symbols-outlined,
.no-font-loading .material-symbols-outlined {
    color: inherit;
}

/* Glass Card Effect - Enhanced */
.glass-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(203, 213, 225, 0.6);
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
}

/* Input Focus Styles */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-fixed);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
}

/* Button Reset */
button {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--outline-variant);
    border-radius: 10px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--outline);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight 0.3s ease-out forwards;
}

.animate-slide-in-left {
    animation: slideInLeft 0.3s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Transitions */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Layout Utilities */
.page-container {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1rem;
}

.header-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Utility Classes */
.text-center-rtl {
    text-align: center;
    direction: rtl;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }

.rounded-sm { border-radius: 0.125rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-full { border-radius: 9999px; }

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --surface: #1a1d22;
        --surface-dim: #121518;
        --surface-bright: #27292d;
        --surface-container-lowest: #0f1114;
        --surface-container-low: #171c21;
        --surface-container: #1d2126;
        --surface-container-high: #27292d;
        --surface-container-highest: #32353b;
        
        --on-surface: #e3e3e7;
        --on-surface-variant: #c7c7cc;
        
        --background: #1a1d22;
        --on-background: #e3e3e7;
        
        --outline-variant: #49454e;
        --outline: #938f96;
    }
    
    body {
        background-color: var(--background);
        color: var(--on-background);
    }
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, var(--surface-container) 0%, var(--surface-container-high) 50%, var(--surface-container) 100%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Gradient Backgrounds */
.gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-container) 100%);
    color: var(--on-primary);
}

.gradient-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-container) 100%);
    color: var(--on-secondary);
}

.gradient-tertiary {
    background: linear-gradient(135deg, var(--tertiary) 0%, var(--tertiary-container) 100%);
    color: var(--on-tertiary);
}

.gradient-error {
    background: linear-gradient(135deg, var(--error) 0%, #ef5350 100%);
    color: var(--on-error);
}

.gradient-sunset {
    background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
    color: white;
}

.gradient-ocean {
    background: linear-gradient(135deg, #0da5de 0%, #06b6d4 100%);
    color: white;
}

.gradient-forest {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: white;
}

.gradient-lavender {
    background: linear-gradient(135deg, #a855f7 0%, #d946ef 100%);
    color: white;
}

/* Card Shadows */
.shadow-elegant {
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(15, 23, 42, 0.06);
}

.shadow-hover {
    transition: box-shadow 0.3s ease;
}

.shadow-hover:hover {
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15), 0 5px 15px rgba(15, 23, 42, 0.08);
}

/* Glow Effects */
.glow-primary {
    box-shadow: 0 0 30px rgba(13, 165, 222, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.glow-secondary {
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.glow-error {
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Responsive Utilities */
@media (max-width: 640px) {
    .hidden-mobile {
        display: none;
    }
}

@media (min-width: 641px) {
    .hidden-desktop {
        display: none;
    }
}

/* Safe Area Support for Mobile Notch */
body {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* Print Styles */
@media print {
    header, nav, .no-print {
        display: none;
    }
}

/* Unified visual refresh */
:root {
    --primary: #0f766e;
    --primary-container: #ccfbf1;
    --on-primary: #ffffff;
    --secondary: #16a34a;
    --secondary-container: #dcfce7;
    --tertiary: #d97706;
    --tertiary-container: #fef3c7;
    --error: #dc2626;
    --error-container: #fee2e2;
    --surface: #fbfdfc;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f2f7f5;
    --surface-container: #e7efec;
    --surface-container-high: #d8e2df;
    --on-surface: #10201d;
    --on-surface-variant: #52615d;
    --outline: #70807b;
    --outline-variant: #d5dfdc;
    --background: #f4faf7;
    --on-background: #10201d;
}

body {
    background:
        radial-gradient(circle at top right, rgba(20, 184, 166, 0.15), transparent 28rem),
        linear-gradient(180deg, #fbfdfc 0%, var(--background) 52%, #eef7f4 100%);
}

.gradient-primary,
.gradient-ocean,
.gradient-lavender,
.gradient-sunset,
.gradient-forest,
.bg-gradient-to-r,
.bg-gradient-to-br {
    background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%) !important;
    color: #ffffff !important;
}

.glass-card,
.shadow-elegant,
section[class*="rounded-2xl"],
div[class*="rounded-2xl"] {
    border-color: rgba(15, 118, 110, 0.14) !important;
    box-shadow: 0 16px 40px rgba(15, 118, 110, 0.10), 0 2px 10px rgba(16, 32, 29, 0.05) !important;
}

.glass-card {
    background: rgba(255, 255, 255, 0.88) !important;
}

input,
select,
textarea {
    background: #ffffff !important;
    border-color: var(--outline-variant) !important;
    color: var(--on-surface) !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18) !important;
}

button,
a {
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

button:active,
a:active {
    transform: scale(0.98);
}

nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 42rem;
    border-radius: 24px 24px 0 0 !important;
}

nav a {
    min-width: 4.2rem;
}

.text-purple-600,
.text-cyan-600,
.text-orange-600,
.text-pink-600,
.text-teal-600,
.text-green-600,
.text-primary {
    color: var(--primary) !important;
}

.border-purple-100,
.border-purple-200,
.border-cyan-100,
.border-cyan-200,
.border-orange-100,
.border-green-200 {
    border-color: rgba(15, 118, 110, 0.18) !important;
}

/* ===== Fix: أزرار الإجراءات في بطاقة الزبون ===== */
/* تعديل لون الكتابة في أزرار "فاتورة جديدة" و"تسجيل دفع" */
a.bg-primary, button.bg-primary {
    background-color: var(--primary-container) !important;
    color: var(--primary) !important;
}

a.bg-secondary, button.bg-secondary {
    background-color: var(--secondary-container) !important;
    color: var(--secondary) !important;
}

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

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

/* ===== Skeleton Loading ===== */
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #e7efec 0%,
        #d0deda 40%,
        #e7efec 80%
    );
    background-size: 800px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-item {
    animation: fadeIn 0.4s ease both;
}
