/* =========================================================
   ZENTRIS ERP - GLOBAL UI/UX DESIGN SYSTEM (PHASE 20)
   STRICTLY VISUAL - NO BUSINESS LOGIC CHANGES
========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Premium Color Palette */
    --primary: #0f172a;        /* Deep Navy */
    --primary-light: #1e293b;
    --accent: #2563eb;         /* Professional Blue */
    --accent-hover: #1d4ed8;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    
    --bg-base: #f8fafc;        /* Very light cool neutral */
    --surface: rgba(255, 255, 255, 0.95); /* Slight glass effect */
    --surface-solid: #ffffff;
    --surface-alt: #f1f5f9;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info: #3b82f6;
    
    /* 3D Depth & Elevation System */
    --border-color: rgba(226, 232, 240, 0.8);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 12px 20px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(37, 99, 235, 0.05);
    --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

/* --- LIGHTWEIGHT ANIMATED BACKGROUND --- */
body {
    background: linear-gradient(-45deg, #f8fafc, #eff6ff, #f1f5f9, #e0e7ff);
    background-size: 400% 400%;
    animation: driftBackground 20s ease-in-out infinite;
    color: var(--text-main);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}
@keyframes driftBackground {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* --- 3D SIDEBAR --- */
.sidebar {
    width: 260px;
    background: var(--surface-solid);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 15px rgba(0,0,0,0.03);
    display: flex; flex-direction: column;
    z-index: 50; transition: transform 0.3s ease;
}
.brand-logo-container {
    padding: 20px; display: flex; align-items: center;
    border-bottom: 1px solid var(--border-color); gap: 12px;
    background: linear-gradient(to bottom, #ffffff, #f8fafc);
}
.brand-logo-placeholder {
    width: 38px; height: 38px; background: var(--accent-gradient); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; border-radius: 10px; font-size: 12px;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}
.brand-logo-text { font-size: 19px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 15px 0; }
.sidebar-section {
    padding: 18px 20px 6px; font-size: 10px; text-transform: uppercase;
    font-weight: 700; color: #94a3b8; letter-spacing: 1px;
}
.sidebar-link {
    display: block; padding: 10px 20px; color: var(--text-muted);
    text-decoration: none; font-weight: 500; font-size: 13px;
    transition: var(--transition); border-left: 3px solid transparent;
    margin: 2px 10px; border-radius: 6px;
}
.sidebar-link:hover { background-color: var(--surface-alt); color: var(--primary); transform: translateX(3px); }
.sidebar-link.active {
    background-color: #eff6ff; color: var(--accent);
    font-weight: 600; box-shadow: inset 3px 0 0 var(--accent);
}

/* --- MAIN CONTENT & GLASSMORPHIC HEADER --- */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; position: relative; }

.top-header {
    height: 70px;
    background: rgba(255, 255, 255, 0.85); /* Glass effect */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 30px; box-shadow: var(--shadow-sm); z-index: 40;
}
.header-title h2 { font-size: 18px; font-weight: 700; margin: 0; color: var(--primary); }
.header-title span { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.header-right { display: flex; align-items: center; gap: 15px; }
.header-user-name { font-weight: 600; font-size: 13px; color: var(--primary); margin-right: 5px; }

/* Settings Icon Button */
.btn-icon {
    background: var(--surface-solid); border: 1px solid var(--border-color);
    border-radius: 50%; width: 36px; height: 36px; display: inline-flex;
    align-items: center; justify-content: center; text-decoration: none;
    color: var(--text-muted); font-size: 16px; transition: var(--transition);
    box-shadow: var(--shadow-sm); cursor: pointer;
}
.btn-icon:hover { background: var(--surface-alt); color: var(--accent); transform: rotate(15deg) scale(1.05); }

/* --- CONTENT BODY & 2D/3D CARDS --- */
.content-body { padding: 30px; overflow-y: auto; flex: 1; animation: fadeIn 0.4s ease-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card, .table-card {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    margin-bottom: 20px;
}
.card:hover, .table-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

/* --- BUTTONS (Dimensional & Animated) --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: var(--transition); border: 1px solid transparent; text-decoration: none;
}
.btn-primary {
    background: var(--accent-gradient); color: white;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-primary:hover {
    transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 15px rgba(37, 99, 235, 0.35);
}
.btn-outline { background: var(--surface-solid); border-color: #cbd5e1; color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: var(--surface-alt); border-color: #94a3b8; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* --- MODERN DATA TABLES --- */
.table-responsive { width: 100%; overflow-x: auto; border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.data-table th {
    background: var(--surface-alt); font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;
    position: sticky; top: 0; z-index: 10;
}
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover { background: rgba(241, 245, 249, 0.8); }

/* --- FORMS --- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--primary-light); }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text-main); transition: var(--transition);
    background: var(--surface-solid); box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
.form-control:focus {
    outline: none; border-color: var(--accent); background: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* --- BADGES --- */
.badge { padding: 5px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; display: inline-block; }
.badge-success { background: var(--success-bg); color: #065f46; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: var(--warning-bg); color: #92400e; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid rgba(239, 68, 68, 0.2); }

/* --- MODALS (Depth & Fade) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--surface-solid); border-radius: var(--radius-lg); width: 90%; max-width: 600px;
    box-shadow: var(--shadow-modal); transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); max-height: 90vh; overflow-y: auto;
}
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-header { padding: 20px 25px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 16px; color: var(--primary); font-weight: 700; }
.btn-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); transition: color 0.2s; }
.btn-close:hover { color: var(--danger); }

/* --- UTILITIES --- */
.hidden { display: none !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }

/* =========================================================
   ANALYTICS EXCEPTION (POWER BI STYLE)
========================================================= */
body.analytics-mode { background: #f3f4f6; animation: none; }
body.analytics-mode .card, body.analytics-mode .table-card {
    border-radius: 4px; border: 1px solid #d1d5db;
    border-top: 4px solid var(--accent); box-shadow: var(--shadow-sm);
    transform: none; backdrop-filter: none; background: #ffffff;
}
body.analytics-mode .card:hover, body.analytics-mode .table-card:hover { transform: none; box-shadow: var(--shadow-sm); }

/* =========================================================
   INVOICE PROTECTION (ABSOLUTE)
========================================================= */
@media print {
    body { background: #fff !important; animation: none !important; }
    .app-wrapper { display: block !important; height: auto !important; overflow: visible !important; }
    .sidebar, .top-header, .no-print { display: none !important; }
    .main-content { padding: 0 !important; overflow: visible !important; }
    .card, .table-card { box-shadow: none !important; border: none !important; padding: 0 !important; transform: none !important; }
}

/* --- RESPONSIVE BEHAVIOR --- */
.mobile-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--primary); }
@media (max-width: 1024px) {
    .sidebar { position: fixed; left: -260px; height: 100%; box-shadow: 10px 0 20px rgba(0,0,0,0.15); }
    .sidebar.open { left: 0; transform: translateX(260px); }
    .mobile-toggle { display: block; }
}


/* =========================================================
   PHASE 20B: SAFE COSMETIC UPGRADES (NO LAYOUT BREAKS)
========================================================= */

/* 1. UPGRADED FORM INPUTS (Dates & Dropdowns) */
input[type="text"], input[type="number"], input[type="date"], 
input[type="email"], input[type="password"], input[type="tel"], 
select, textarea {
    appearance: none; -webkit-appearance: none;
    width: 100%; padding: 10px 14px;
    border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text-main); 
    background-color: var(--surface-solid);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
    transition: var(--transition); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15), inset 0 1px 2px rgba(0,0,0,0.02);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
    padding-right: 40px; cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer; opacity: 0.6; transition: opacity 0.2s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* 2. MODAL FORM LAYOUTS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-grid.full { grid-template-columns: 1fr; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* Safely space forms inside modals */
.modal-content form { padding: 20px 24px; }

/* 3. SAFE MODAL FOOTER */
.modal-footer {
    padding: 16px 24px;
    background: var(--surface-alt);
    border-top: 1px solid var(--border-color);
    display: flex; justify-content: flex-end; gap: 12px;
}
/* Curve footer if it sits at the bottom of a form */
.modal-content form .modal-footer {
    margin: 20px -24px -24px -24px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* 4. UNIVERSAL MODAL BUTTONS (GRADIENTS) */
.modal-footer button[type="submit"],
.modal-footer .btn-primary,
#btnSaveCustomer, #btnSubmitPayment,
#btnSaveSupplier, #btnConfirmAdjustment,
#btnSaveProduct, #btnSaveCategory, #btnSubmitExpense,
.modal-footer button[onclick*="print"],
.modal-footer button[onclick*="Print"] {
    background: var(--accent-gradient);
    color: white; border: none; border-radius: var(--radius-sm);
    padding: 9px 18px; font-weight: 600; font-size: 13px;
    cursor: pointer; box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
    transition: var(--transition);
}
.modal-footer button[type="submit"]:hover,
.modal-footer .btn-primary:hover,
#btnSaveCustomer:hover, #btnSubmitPayment:hover,
#btnSaveSupplier:hover, #btnConfirmAdjustment:hover,
#btnSaveProduct:hover, #btnSaveCategory:hover, #btnSubmitExpense:hover,
.modal-footer button[onclick*="print"]:hover,
.modal-footer button[onclick*="Print"]:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.35);
}

/* OUTLINE / CANCEL / CLOSE BUTTONS */
.modal-footer button[type="button"],
.modal-footer .btn-outline,
#btnCancelModal, #btnCloseModal, #btnCloseSaleModal {
    background: #ffffff; color: var(--primary);
    border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
    padding: 9px 18px; font-weight: 600; font-size: 13px;
    cursor: pointer; transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.modal-footer button[type="button"]:hover,
.modal-footer .btn-outline:hover,
#btnCancelModal:hover, #btnCloseModal:hover, #btnCloseSaleModal:hover {
    background: var(--surface-alt); border-color: #94a3b8; transform: translateY(-1px);
}

/* 5. SALE DETAILS MODAL WIDTH */
.modal-content.modal-lg, .modal.modal-lg .modal-content, #saleDetailsModal .modal-content {
    max-width: 800px;
}