/* style.css - TeraMax Server Accounting System */

/* 1. THEME DEFINITIONS & GLOBAL VARIABLES */
:root {
    --transition-speed: 0.3s;
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --font-primary: 'Outfit', 'Cairo', sans-serif;
}

/* Theme: Gold Master (Obsidian & Premium Gold) */
.theme-gold {
    --bg-primary: #121214;
    --bg-surface: #1e1e24;
    --bg-surface-hover: #2a2a32;
    --border-color: rgba(212, 175, 55, 0.15);
    --border-color-focus: rgba(212, 175, 55, 0.5);
    --text-primary: #ffffff;
    --text-secondary: #a0a0ab;
    --text-muted: #6b6b76;
    --primary: #d4af37; /* Metallic Gold */
    --primary-rgb: 212, 175, 55;
    --primary-hover: #e5c158;
    --accent: #aa8c2c;
    --glass-bg: rgba(30, 30, 36, 0.7);
    --glass-blur: 15px;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

/* Theme: Silver Steel */
.theme-silver {
    --bg-primary: #18191c;
    --bg-surface: #24262b;
    --bg-surface-hover: #2f3238;
    --border-color: rgba(192, 192, 192, 0.15);
    --border-color-focus: rgba(192, 192, 192, 0.5);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --primary: #c0c0c0; /* Metallic Silver */
    --primary-rgb: 192, 192, 192;
    --primary-hover: #d1d5db;
    --accent: #9ca3af;
    --glass-bg: rgba(36, 38, 43, 0.7);
    --glass-blur: 15px;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

/* Theme: Charcoal Black (Obsidian Minimal) */
.theme-charcoal {
    --bg-primary: #0a0a0a;
    --bg-surface: #141414;
    --bg-surface-hover: #1e1e1e;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-focus: rgba(255, 255, 255, 0.3);
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #525252;
    --primary: #ffffff; 
    --primary-rgb: 255, 255, 255;
    --primary-hover: #e5e5e5;
    --accent: #737373;
    --glass-bg: rgba(20, 20, 20, 0.8);
    --glass-blur: 20px;
    
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;
}

/* Theme: Emerald Forest */
.theme-emerald {
    --bg-primary: #0b130e;
    --bg-surface: #122218;
    --bg-surface-hover: #1b3324;
    --border-color: rgba(16, 185, 129, 0.15);
    --border-color-focus: rgba(16, 185, 129, 0.5);
    --text-primary: #f0fdf4;
    --text-secondary: #a7f3d0;
    --text-muted: #34d399;
    --primary: #10b981; /* Emerald Green */
    --primary-rgb: 16, 185, 129;
    --primary-hover: #34d399;
    --accent: #059669;
    --glass-bg: rgba(18, 34, 24, 0.7);
    --glass-blur: 15px;
    
    --success: #10b981;
    --danger: #f87171;
    --warning: #fbbf24;
}

/* Theme: Sapphire Blue */
.theme-sapphire {
    --bg-primary: #080e1a;
    --bg-surface: #111b2f;
    --bg-surface-hover: #1b2a47;
    --border-color: rgba(59, 130, 246, 0.15);
    --border-color-focus: rgba(59, 130, 246, 0.5);
    --text-primary: #eff6ff;
    --text-secondary: #bfdbfe;
    --text-muted: #60a5fa;
    --primary: #3b82f6; /* Sapphire Blue */
    --primary-rgb: 59, 130, 246;
    --primary-hover: #60a5fa;
    --accent: #2563eb;
    --glass-bg: rgba(17, 27, 47, 0.7);
    --glass-blur: 15px;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

/* 2. BASE AND CONTAINER STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    overflow-x: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition-speed), background var(--transition-speed);
}

.sidebar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
}

.logo-image {
    max-width: 180px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    transition: transform var(--transition-speed);
}

.logo-image:hover {
    transform: scale(1.05);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all var(--transition-speed);
}

.nav-item i {
    font-size: 1.2rem;
    transition: transform var(--transition-speed);
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.nav-item.active {
    border-right: 4px solid var(--primary);
    background-color: rgba(var(--primary-rgb), 0.15);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    padding: 10px;
    cursor: pointer;
    font-family: var(--font-primary);
    font-weight: 600;
    transition: all var(--transition-speed);
}

.sidebar-btn:hover {
    background: rgba(var(--primary-rgb), 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.backup-quick-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.backup-quick-info i {
    color: var(--success);
}

/* Main Content Styling */
.main-content {
    margin-right: 280px; /* Offset for sidebar */
    flex-grow: 1;
    padding: 40px;
    min-height: 100vh;
}

/* App Header Styling */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.header-title-area h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(45deg, var(--text-primary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 1rem;
}

.header-date {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary);
}

/* 3. DYNAMIC VIEWPORTS AND VISIBILITY */
.viewport-container {
    position: relative;
    width: 100%;
}

.viewport-view {
    display: none;
    animation: fadeIn 0.4s ease-in-out forwards;
}

.viewport-view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 4. KPI CARDS STYLING */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--bg-surface);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    transition: all var(--transition-speed);
}

.kpi-card:hover {
    transform: translateY(-5px);
    border-color: rgba(var(--primary-rgb), 0.4);
    box-shadow: 0 15px 30px rgba(0,0,0,0.35);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #ffffff;
}

.kpi-card.revenue .kpi-icon {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.kpi-card.revenue.usd .kpi-icon {
    background: linear-gradient(135deg, #d97706, #fbbf24);
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

.kpi-card.expense .kpi-icon {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.kpi-card.expense.usd .kpi-icon {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    margin-top: 6px;
    color: var(--text-primary);
}

.kpi-card.revenue .kpi-value {
    color: var(--success);
}

.kpi-card.expense .kpi-value {
    color: var(--danger);
}

/* Profit KPI Grid styling */
.profit-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.profit-card {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(var(--primary-rgb), 0.02));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.profit-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.05) 0%, transparent 60%);
    pointer-events: none;
}

.profit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 700;
}

.profit-header i {
    font-size: 1.4rem;
    color: var(--primary);
}

.profit-body {
    margin-top: 20px;
}

.profit-body h2 {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3);
}

.profit-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 10px;
}

/* 5. GLASS PANELS & GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 30px;
    margin-bottom: 35px;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-header i {
    font-size: 1.3rem;
    color: var(--primary);
}

.card-body {
    padding: 28px;
}

.chart-container {
    height: 350px;
    position: relative;
}

/* Reconciliation Dashboard Box */
.reconciliation-summary {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-md);
    padding: 20px;
    margin-bottom: 20px;
    border-right: 4px solid var(--primary);
}

.reconciliation-summary h4 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.reconciliation-summary p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.settlement-steps {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.settlement-step-card {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideIn 0.3s ease forwards;
}

.settlement-step-card.danger {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-title {
    font-weight: 700;
    font-size: 1rem;
}

.step-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.settlement-step-card.danger .step-badge {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border-color: var(--danger);
}

/* 6. TABLES AND BADGES */
.table-panel {
    margin-bottom: 35px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.table th, .table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.95rem;
    background: rgba(255,255,255,0.02);
}

.table tbody tr {
    transition: background-color var(--transition-speed);
}

.table tbody tr:hover {
    background-color: rgba(255,255,255,0.02);
}

.table td {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-gold {
    background-color: rgba(212, 175, 55, 0.15);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

/* 7. SPLIT LAYOUTS FOR FORMS AND LISTS */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1.8fr;
    gap: 30px;
    align-items: start;
}

.split-layout.reverse {
    grid-template-columns: 1.8fr 1fr;
}

.form-panel {
    position: sticky;
    top: 40px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: all var(--transition-speed);
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.2);
    background: rgba(0, 0, 0, 0.3);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-tip {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.5);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
}

.btn-danger-light {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 6px 12px;
}

.btn-danger-light:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--danger);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.85rem;
}

.w-full {
    width: 100%;
}

.mb-3 { margin-bottom: 12px; }
.mt-4 { margin-top: 16px; }

.cursor-pointer {
    cursor: pointer;
}

/* Alert Boxes */
.card-alert {
    padding: 15px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.5;
}

.card-alert.mt-4 {
    margin-top: 20px;
}

#shares-sum-alert {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

#shares-sum-alert.success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #34d399;
}

/* Search bar styling */
.table-search {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 4px 16px;
    width: 280px;
}

.table-search i {
    color: var(--text-secondary);
    margin-left: 8px;
}

.table-search input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    font-family: var(--font-primary);
    font-size: 0.88rem;
}

.table-search input:focus {
    outline: none;
}

/* Pagination Styling */
.pagination-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
}

.pagination-buttons button {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* 8. PARTNER CARDS GRID */
.partners-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.partner-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
    position: relative;
    transition: all var(--transition-speed);
}

.partner-card:hover {
    border-color: var(--primary);
    background: rgba(255,255,255,0.04);
    transform: translateY(-3px);
}

.partner-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.partner-card-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.partner-card-share {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.partner-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.partner-stat-item {
    display: flex;
    flex-direction: column;
}

.partner-stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.partner-stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 4px;
}

.partner-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* 9. SMART FILTERS & REPORTS */
.filters-panel {
    margin-bottom: 30px;
}

.filters-grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-actions-full {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    margin-top: 10px;
}

.filter-results-summary {
    animation: fadeIn 0.4s ease forwards;
}

.kpi-sub-values {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 6px;
}

.kpi-card.net .kpi-info {
    color: var(--primary);
}

/* 10. SETTINGS & CUSTOM THEMES & BACKUP */
.settings-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.settings-right-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.themes-selector-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.01);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.theme-option:hover {
    background: rgba(255,255,255,0.03);
    border-color: var(--primary);
}

.theme-option.active {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.1);
}

.theme-preview {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.theme-preview.gold { background: linear-gradient(135deg, #d4af37, #121214); }
.theme-preview.silver { background: linear-gradient(135deg, #c0c0c0, #18191c); }
.theme-preview.charcoal { background: linear-gradient(135deg, #ffffff, #0a0a0a); }
.theme-preview.emerald { background: linear-gradient(135deg, #10b981, #0b130e); }
.theme-preview.sapphire { background: linear-gradient(135deg, #3b82f6, #080e1a); }

.backup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.import-wrapper {
    position: relative;
}

/* 11. PRINT AND INVOICE STYLING */
.print-only {
    display: none;
}

@media print {
    /* Hide all screen components */
    body * {
        visibility: hidden;
    }
    
    .app-container, .sidebar, .main-content, .viewport-container, .viewport-view {
        display: none !important;
    }
    
    /* Show the print layout shell and its contents */
    #print-layout-shell, #print-layout-shell * {
        visibility: visible;
    }
    
    #print-layout-shell {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        color: #000000 !important;
        background: #ffffff !important;
        padding: 20px;
        direction: rtl; /* Enforce RTL layout for printing invoice */
        font-family: 'Cairo', sans-serif;
    }
    
    /* Styled print header */
    .print-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 25px;
    }
    
    .print-logo-container {
        width: 140px;
    }
    
    .print-logo {
        width: 100%;
        height: auto;
        filter: grayscale(1) contrast(1.2); /* Black and white print friendly logo */
    }
    
    .print-title-details {
        text-align: right;
        flex-grow: 1;
        margin-right: 30px;
    }
    
    .print-title-details h1 {
        font-size: 1.8rem;
        font-weight: 800;
        margin-bottom: 4px;
        color: #000000;
    }
    
    .print-title-details p {
        font-size: 0.9rem;
        color: #444444;
    }
    
    .print-meta {
        text-align: left;
        font-size: 0.85rem;
        line-height: 1.6;
    }
    
    .print-divider {
        border: none;
        border-top: 2px solid #000000;
        margin-bottom: 20px;
    }
    
    /* Print Table styling */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin: 25px 0;
        font-size: 0.85rem;
    }
    
    .print-table th, .print-table td {
        border: 1px solid #000000;
        padding: 10px 12px;
        text-align: right;
    }
    
    .print-table th {
        background-color: #f2f2f2 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: 700;
    }
    
    /* Printed report summary metrics */
    .print-summary-box {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        background: #f8f8f8 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        border: 1px solid #ccc;
        border-radius: 6px;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .print-summary-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .print-summary-label {
        font-size: 0.8rem;
        color: #555555;
    }
    
    .print-summary-value {
        font-size: 1.1rem;
        font-weight: 700;
    }
    
    /* Signatures line */
    .print-signatures {
        display: flex;
        justify-content: space-between;
        margin-top: 60px;
        margin-bottom: 40px;
    }
    
    .sig-box {
        width: 250px;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .sig-line {
        border-top: 1px dashed #000000;
        margin-top: 45px;
        width: 100%;
    }
    
    .print-footer {
        border-top: 1px solid #e0e0e0;
        padding-top: 15px;
        text-align: center;
        font-size: 0.75rem;
        color: #777777;
        position: relative;
    }
    
    .print-note {
        font-style: italic;
        margin-bottom: 8px;
        font-size: 0.8rem;
        color: #333333;
    }
}

/* 12. RESPONSIVENESS AND ARABIC DIRECTION FIXES */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
}

[dir="rtl"] .main-content {
    margin-right: 280px;
    margin-left: 0;
}

/* English Direction Support */
[dir="ltr"] body {
    direction: ltr;
}

[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-color);
}

[dir="ltr"] .main-content {
    margin-right: 0;
    margin-left: 280px;
}

[dir="ltr"] .nav-item.active {
    border-right: none;
    border-left: 4px solid var(--primary);
}

[dir="ltr"] .table, [dir="ltr"] .table th, [dir="ltr"] .table td {
    text-align: left;
}

[dir="ltr"] .table-search i {
    margin-left: 0;
    margin-right: 8px;
}

[dir="ltr"] .print-title-details {
    text-align: left;
    margin-right: 0;
    margin-left: 30px;
}

[dir="ltr"] .print-meta {
    text-align: right;
}

[dir="ltr"] .print-table th, [dir="ltr"] .print-table td {
    text-align: left;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 1024px) {
    .split-layout, .split-layout.reverse {
        grid-template-columns: 1fr;
    }
    .form-panel {
        position: static;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .profit-kpi-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%); /* Hide sidebar by default on mobile */
        /* In an actual implementation, a hamburger menu toggle button is used to show/hide the sidebar */
    }
    
    .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
        padding: 20px;
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

/* 13. SECURE LOGIN SCREEN OVERLAY STYLING */
.login-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 30% 30%, var(--bg-surface) 0%, var(--bg-primary) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Higher than everything */
    padding: 20px;
    animation: fadeIn 0.5s ease-out;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 25px 55px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    max-width: 160px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.login-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Captcha Badge Styling */
.captcha-badge {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.25), rgba(var(--primary-rgb), 0.05));
    border: 1px solid var(--primary);
    color: var(--primary);
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 4px;
    padding: 8px 16px;
    border-radius: var(--border-radius-sm);
    text-shadow: 0 0 10px rgba(var(--primary-rgb), 0.3);
    user-select: none;
    min-width: 80px;
    text-align: center;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 4px);
}

/* Header Active User Status Badge */
.header-user-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(var(--primary-rgb), 0.1);
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary);
}

.header-user-status i {
    font-size: 1.1rem;
}
