/* style.css - Premium CRM-themed visual enhancements for Mon Carnet (credit.rosahost.com) */

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Base resets & iOS elastic scroll fix */
html {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-text-size-adjust: 100%;
}

body {
    padding-top: var(--safe-top);
    padding-bottom: calc(7rem + var(--safe-bottom));
    font-size: 16px; /* Prevents iOS Safari auto-zoom on inputs */
}

.safe-top {
    padding-top: calc(0.875rem + var(--safe-top));
}

.safe-bottom {
    padding-bottom: calc(1.5rem + var(--safe-bottom));
}

/* Ensure all inputs are at least 16px to prevent iOS auto-zoom */
input, select, textarea {
    font-size: 16px !important;
}

/* Custom fonts styling for Arabic support */
[lang="ar"] body,
[lang="ar"] input,
[lang="ar"] button,
[lang="ar"] select,
[lang="ar"] textarea {
    font-family: 'Tajawal', 'Almarai', sans-serif !important;
}

[lang="ar"] .font-mono {
    font-family: 'Inter', monospace !important;
    letter-spacing: -0.025em;
}

/* Custom Scrollbar - slightly wider on mobile for better touch */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 99px;
}

/* Glassmorphism subtle reflections (identical to crm.rosahost.com) */
.glass-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Timeline vertical line in Ledger drawer - positioned to center with 40px icons */
#ledger-history-container {
    position: relative;
}

#ledger-history-container::before {
    content: '';
    position: absolute;
    top: 1.5rem;
    bottom: 1.5rem;
    width: 2px;
    background: rgba(255, 255, 255, 0.06);
    left: calc(1.5rem + 19px); /* center of 40px icon */
}

html[dir="rtl"] #ledger-history-container::before {
    left: auto;
    right: calc(1.5rem + 19px);
}

/* Custom drawer and modal behaviors */
#ledger-drawer, #settings-drawer {
    transition: visibility 0.3s;
}

#ledger-drawer.pointer-events-none {
    visibility: hidden;
}

#ledger-drawer.pointer-events-auto {
    visibility: visible;
}

#settings-drawer.pointer-events-none {
    visibility: hidden;
}

#settings-drawer.pointer-events-auto {
    visibility: visible;
}

/* Autocomplete highlight styling - clear visual feedback */
.autocomplete-item.active {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

html[dir="rtl"] .autocomplete-item.active {
    border-left: none;
    border-right: 3px solid rgba(255, 255, 255, 0.3);
}

/* Premium animation keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-fade-in {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Quick tags active-pulse styling (Matches CRM slate brand theme) */
.tag-active {
    background-color: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.06);
    transform: scale(1.02);
}

/* Removing input default numeric spinner wheels for a clean tabular layout */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Fast highlight animation on card tap */
@keyframes touchRipple {
    0% {
        background-color: rgba(255, 255, 255, 0.04);
    }
    100% {
        background-color: transparent;
    }
}

.tap-active-ripple:active {
    animation: touchRipple 0.4s ease-out;
}

/* Mobile-specific improvements */
@media (max-width: 640px) {
    /* Larger touch targets on small screens */
    button, a, [role="button"] {
        min-height: 44px;
    }
    
    /* Slightly larger text on mobile */
    .text-xs {
        font-size: 0.8125rem; /* 13px instead of 12px */
        line-height: 1.4;
    }
    
    /* Better spacing on mobile */
    .space-y-3.5 > * + * {
        margin-top: 1rem;
    }
    
    .space-y-4 > * + * {
        margin-top: 1.125rem;
    }
}

/* Focus-visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.3);
    outline-offset: 2px;
    border-radius: 8px;
}

/* Smooth transitions for all interactive elements */
button, a, input, select, textarea {
    transition-property: color, background-color, border-color, transform, opacity, box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* ==========================================
   PRINTING SYSTEM (Documents / PDF generation)
   ========================================== */
#print-section {
    display: none;
}

@media print {
    /* Hide everything on screen */
    body * {
        visibility: hidden !important;
        background: transparent !important;
    }
    
    /* Only show the print section */
    #print-section, #print-section * {
        visibility: visible !important;
    }
    
    #print-section {
        display: block !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        color: #000000 !important;
        background: #ffffff !important;
        padding: 2rem !important;
        box-sizing: border-box !important;
    }

    /* Print-specific style resets */
    .print-border {
        border: 1px solid #cbd5e1 !important;
    }
    .print-border-b {
        border-bottom: 1px solid #e2e8f0 !important;
    }
    .print-text-dark {
        color: #0f172a !important;
    }
    .print-text-muted {
        color: #64748b !important;
    }
    .print-bg-light {
        background-color: #f8fafc !important;
    }
    .print-bg-header {
        background-color: #0f172a !important;
        color: #ffffff !important;
    }
}

/* ==========================================
   OFF-SCREEN RENDERING SYSTEM (Image generation)
   ========================================== */
#image-export-target {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 480px;
    background: #030712;
    color: #f8fafc;
    border-radius: 24px;
    padding: 2rem;
    box-sizing: border-box;
    z-index: -100;
}

