/* =================================================================== */
/* QZ CPA Stylesheet - V2 with UI/UX Enhancements                    */
/* =================================================================== */

/* --- 0. FONT IMPORT & ROOT VARIABLES --- */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');

:root {
    --bg-dark: #1A1D24;
    --bg-light: #252A34;
    --accent-blue: #0A84FF;
    --accent-blue-light: #3399FF;
    --text-primary: #FFFFFF;
    --text-secondary: #A0AEC0;
    --border-color: #323946;
    --font-family: 'Tajawal', sans-serif;
    /* --- NEW: Shadow variables for consistency --- */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

/* --- 1. GLOBAL RESET & BODY STYLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-family);
    direction: rtl;
    font-size: 16px;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* --- NEW: Subtle animated grid background for the whole app --- */
body::before {
    content: '';
    position: fixed; /* Use fixed to cover the viewport */
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background-image:
        linear-gradient(rgba(50, 57, 70, 0.15) 1px, transparent 1px), /* Lighter lines */
        linear-gradient(90deg, rgba(50, 57, 70, 0.15) 1px, transparent 1px);
    background-size: 75px 75px; /* Larger grid */
    animation: pan-grid 180s linear infinite;
    z-index: -1; /* Place it behind all content */
}

/* --- 2. NEW LOGIN PAGE STYLES (No Change) --- */
.login-page-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
}

.login-branding-section {
    flex: 1;
    background-color: transparent; /* Make it transparent to see body background */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    position: relative;
    overflow: hidden;
}

/* The login page grid can be more pronounced */
.login-branding-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background-image:
        linear-gradient(rgba(50, 57, 70, 0.5) 1px, transparent 1px),
        linear-gradient(90deg, rgba(50, 57, 70, 0.5) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: pan-grid 120s linear infinite;
    z-index: 0;
}

.logo-large {
    font-size: 64px;
    font-weight: 700;
    color: var(--text-primary);
    border: 3px solid var(--accent-blue);
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    z-index: 1;
    background-color: var(--bg-dark); /* Add background to stand out */
}

.welcome-message {
    color: var(--text-secondary);
    font-size: 20px;
    text-align: center;
    line-height: 1.6;
    z-index: 1;
}

.login-form-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.form-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.form-container h2 {
    font-size: 32px;
    margin-bottom: 25px;
    text-align: center;
}

/* --- 3. MAIN APP LAYOUT (Page Load Animation) --- */
.app-layout {
    width: 100%;
}
.main-content {
    padding: 30px 30px 120px 30px; 
    width: 100%;
    min-height: 100vh;
    /* --- NEW: Page load animation starting state --- */
    opacity: 0;
    transform: translateY(20px);
    animation: slide-fade-in 0.6s ease-out forwards;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}
.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.logo-container:hover { transform: scale(1.05); }
.logo {
    background-color: var(--accent-blue);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    border-radius: 6px;
    padding: 8px 12px;
    line-height: 1;
}
.app-name {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
}
.page-header h2 { font-size: 28px; margin: 0 auto; }
.user-profile { font-size: 24px; color: var(--text-secondary); cursor: pointer; }

/* --- 4. BOTTOM NAVIGATION BAR (Subtle Enhancement) --- */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-light);
    padding: 8px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    /* --- UPDATED: Use shadow variable --- */
    box-shadow: var(--shadow-lg);
}
.bottom-nav a { position: relative; display: flex; justify-content: center; align-items: center; width: 48px; height: 48px; border-radius: 50%; text-decoration: none; color: var(--text-secondary); font-size: 20px; transition: all 0.3s ease; }
.bottom-nav a:hover { color: var(--text-primary); background-color: var(--border-color); }
.bottom-nav a.active { background-color: var(--accent-blue); color: var(--text-primary); }
.bottom-nav a::before { content: attr(data-title); position: absolute; bottom: 120%; background-color: var(--bg-dark); color: var(--text-primary); padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 14px; font-weight: 500; white-space: nowrap; opacity: 0; transform: translateY(10px); pointer-events: none; transition: all 0.3s ease; }
.bottom-nav a:hover::before { opacity: 1; transform: translateY(0); }

/* --- 5. DASHBOARD & OTHER COMPONENTS (Enhanced) --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card { background-color: var(--bg-light); padding: 20px; border-radius: 8px; /* --- UPDATED: Add shadow --- */ box-shadow: var(--shadow-sm); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.kpi-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.kpi-card h4 { color: var(--text-secondary); font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.kpi-card p { font-size: 28px; font-weight: 700; }
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 30px; }
.chart-container, .table-container { background-color: var(--bg-light); padding: 20px; border-radius: 8px; /* --- UPDATED: Add shadow --- */ box-shadow: var(--shadow-md); }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.chart-header h3 { font-size: 18px; }

/* --- 6. TABLE, BUTTON & MODAL STYLES (Enhanced) --- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { text-align: right; padding: 12px 15px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); font-weight: 500; font-size: 14px; }
.data-table tbody tr { border-bottom: 1px solid var(--border-color); transition: background-color 0.3s ease; opacity: 0; animation: table-row-in 0.5s ease forwards; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background-color: rgba(30, 41, 59, 0.5); }
.data-table td { padding: 15px; vertical-align: middle; }

/* --- UPDATED: Enhanced button styles --- */
.btn { padding: 10px 20px; border: none; border-radius: 6px; font-family: var(--font-family); font-size: 15px; font-weight: 700; cursor: pointer; transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { 
    background: linear-gradient(45deg, var(--accent-blue), var(--accent-blue-light)); /* Gradient */
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { 
    background-color: var(--accent-blue-light); 
    transform: translateY(-2px); 
    box-shadow: 0 4px 15px rgba(10, 132, 255, 0.4); /* Enhanced shadow on hover */
}

.btn-action { background-color: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); padding: 6px 10px; font-size: 13px; margin: 0 2px; }
.btn-action:hover { color: var(--text-primary); border-color: var(--accent-blue); }

/* --- UPDATED: Modal styles for new animations --- */
.modal-backdrop { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(5px); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 3000; 
    /* Base styles for animation */
    opacity: 0; 
    animation: fade-in 0.3s ease-out forwards; 
}
.modal-content { 
    background-color: var(--bg-light); 
    padding: 30px; 
    border-radius: 8px; 
    border: 1px solid var(--border-color); 
    width: 100%; max-width: 500px; 
    box-shadow: var(--shadow-lg);
    /* Base styles for animation */
    transform: scale(0.95);
    animation: scale-in 0.3s 0.1s ease-out forwards;
}
/* NEW: Closing animation classes */
.modal-backdrop.closing { animation: fade-out 0.3s ease-in forwards; }
.modal-content.closing { animation: scale-out 0.3s ease-in forwards; }

.modal-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; margin-bottom: 20px; }
.modal-close-btn { background: none; border: none; color: var(--text-secondary); font-size: 24px; cursor: pointer; }
.form-actions { margin-top: 20px; text-align: left; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 14px; }
.form-group input { width: 100%; padding: 12px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 16px; transition: border-color 0.3s, box-shadow 0.3s; }
.form-group input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.25); }


/* --- 7. KEYFRAME ANIMATIONS (Updated & New) --- */
@keyframes pan-grid {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-50%, -50%); }
}
@keyframes table-row-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* UPDATED */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* NEW: Animations for page load and modal close */
@keyframes slide-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes scale-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.95); } }


/* --- Remaining styles are unchanged but included for completeness --- */

/* --- 8. UTILITY CLASSES (NO CHANGE) --- */
.text-center { text-align: center; }
.p-4 { padding: 1.5rem; }

/* --- Chat Interface Styles --- */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 180px); background-color: var(--bg-light); border-radius: 8px; overflow: hidden; }
.chat-window { flex-grow: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.chat-message { padding: 12px 18px; border-radius: 18px; max-width: 75%; line-height: 1.6; opacity: 0; transform: translateY(10px); animation: table-row-in 0.5s ease forwards; }
.user-message { background-color: var(--accent-blue); color: var(--text-primary); align-self: flex-start; border-top-left-radius: 5px; }
.ai-message { background-color: var(--bg-dark); color: var(--text-secondary); align-self: flex-end; border-top-right-radius: 5px; }
.chat-input-area { display: flex; padding: 15px; gap: 10px; border-top: 1px solid var(--border-color); }
.chat-input-area input { flex-grow: 1; padding: 12px 18px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 50px; color: var(--text-primary); font-size: 16px; }
.chat-input-area input:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2); }
.chat-input-area button { border-radius: 50%; width: 48px; height: 48px; padding: 0; font-size: 18px; }

/* --- Status Indicator Styles --- */
.status { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; display: inline-block; }
.status-unpaid { background-color: rgba(255, 165, 0, 0.15); color: #FFA500; }
.status-paid { background-color: rgba(0, 255, 127, 0.15); color: #00FF7F; }
.status-overdue { background-color: rgba(255, 69, 0, 0.15); color: #FF4500; }

/* --- Admin Grid Styles --- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; }
.form-section-admin, .info-panel { background-color: var(--bg-light); padding: 25px; border-radius: 8px; }
.form-section-admin h3, .info-panel h3 { font-size: 18px; margin-bottom: 20px; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); padding-bottom: 10px; }
.response-message { margin-top: 15px; padding: 12px; border-radius: 6px; font-weight: 500; display: none; }
.response-message.success { background-color: rgba(16, 185, 129, 0.1); color: #10B981; display: block; }
.response-message.error { background-color: rgba(239, 68, 68, 0.1); color: #EF4444; display: block; }

/* --- Invoice Creator Page Styles --- */
.invoice-creator-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 992px) {
    .invoice-creator-grid { grid-template-columns: 250px 1fr; grid-template-areas: "details items" "totals  items"; }
    .form-section { grid-area: details; }
    .items-section { grid-area: items; }
    .totals-section { grid-area: totals; }
}
.form-section, .items-section, .totals-section { background-color: var(--bg-light); padding: 20px; border-radius: 8px; }
.items-section .data-table td { padding: 8px 15px; }
.totals-section h3, .form-section h3, .items-section h3 { font-size: 18px; margin-bottom: 20px; color: var(--text-secondary); }
.total-row { display: flex; justify-content: space-between; padding: 10px 0; font-size: 16px; }
.total-row span:first-child { color: var(--text-secondary); }
.total-row input { background: var(--bg-dark); border: 1px solid var(--border-color); color: var(--text-primary); padding: 5px; border-radius: 4px; width: 100px; text-align: right; }
.totals-divider { border: none; height: 1px; background-color: var(--border-color); margin: 10px 0; }
.grand-total { font-size: 20px; font-weight: 700; }
.grand-total span { color: var(--text-primary) !important; }
.btn-secondary { background-color: var(--border-color); color: var(--text-secondary); }
.btn-secondary:hover { background-color: #4A5568; color: var(--text-primary); }

/* --- Settings Page Styles --- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; }
.settings-card { background-color: var(--bg-light); padding: 25px; border-radius: 8px; }
.settings-card h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 25px; display: flex; align-items: center; gap: 10px; }
.file-upload-wrapper { position: relative; border: 2px dashed var(--border-color); border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: border-color 0.3s ease; }
.file-upload-wrapper:hover { border-color: var(--accent-blue); }
.file-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-upload-display { display: flex; flex-direction: column; align-items: center; gap: 15px; color: var(--text-secondary); }
#logoPreview { width: 100px; height: 100px; object-fit: contain; border-radius: 50%; background-color: var(--bg-dark); }
.form-control-file { display: block; width: 100%; padding: 10px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); }
select.form-control { width: 100%; padding: 12px; background-color: var(--bg-dark); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 16px; }
.coming-soon { display: flex; justify-content: space-between; align-items: center; background-color: var(--bg-dark); padding: 12px; border-radius: 6px; }
.badge { background-color: var(--accent-blue); padding: 4px 8px; font-size: 12px; border-radius: 4px; }
.settings-actions { margin-top: 20px; text-align: left; }

/* Financial Actions Buttons */
.actions-financial .btn-action { border-radius: 20px; padding: 6px 15px; }
.btn-payment { border-color: #2ECC71 !important; color: #2ECC71 !important; }
.btn-payment:hover { background-color: #2ECC71 !important; color: var(--text-primary) !important; }
.btn-statement { border-color: var(--accent-blue-light) !important; color: var(--accent-blue-light) !important; }
.btn-statement:hover { background-color: var(--accent-blue-light) !important; color: var(--text-primary) !important; }