/* ==========================================================================
   TRAVELTARA MASTER ADMIN DASHBOARD - ENTERPRISE STYLESHEET
   100% FLUID, MOBILE-FIRST, ZERO-BREAK ARCHITECTURE
   ========================================================================== */

/* --- 1. GLOBAL RESETS & VARIABLES --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-dark: #0A1128;
    --primary-gold: #C5A059;
    --bg-light: #f4f5f7;
    --text-dark: #333;
    --border-light: #eee;
    --success: #27ae60;
    --danger: #e74c3c;
    --info: #2980b9;
}

html, body { 
    font-family: 'Lato', sans-serif; 
    background: var(--bg-light); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
    display: flex;
    color: var(--text-dark);
}

/* --- 2. MOBILE TOPBAR (Strictly Hidden on Desktop) --- */
.mobile-topbar {
    display: none;
    background: var(--primary-dark);
    color: #fff;
    padding: 15px 20px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    width: 100%;
    height: 60px;
}
.mobile-topbar h2 { 
    font-family: 'Playfair Display', serif; 
    color: var(--primary-gold); 
    font-size: 1.2rem; 
}
.menu-toggle-btn { 
    background: none; border: none; color: #fff; 
    font-size: 1.5rem; cursor: pointer; 
}

/* --- 3. SIDEBAR NAVIGATION --- */
.sidebar { 
    width: 260px; 
    min-width: 260px; 
    flex-shrink: 0; 
    background: var(--primary-dark); 
    color: #fff; 
    display: flex; 
    flex-direction: column; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.1); 
    z-index: 1001; 
    height: 100vh;
    overflow-y: auto; 
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}
.sidebar-header { padding: 25px 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-family: 'Playfair Display', serif; color: var(--primary-gold); font-size: 1.5rem; }
.sidebar-header p { font-size: 0.8rem; color: #aaa; margin-top: 5px; }

.nav-menu { display: flex; flex-direction: column; padding: 20px 0; flex-grow: 1; }
.nav-link { 
    padding: 15px 25px; color: #ddd; text-decoration: none; 
    display: flex; align-items: center; gap: 10px; cursor: pointer; 
    border-left: 4px solid transparent; transition: all 0.3s ease; user-select: none; 
}
.nav-link:hover, .nav-link.active { 
    background: rgba(197, 160, 89, 0.1); color: var(--primary-gold); 
    border-left-color: var(--primary-gold); 
}
.dropdown-container { display: none; background: #050814; }
.dropdown-container.show { display: block; }
.sub-link { padding-left: 45px; font-size: 0.9rem; }
.dropdown-icon { margin-left: auto; transition: transform 0.3s; }
.nav-link.dropdown-active .dropdown-icon { transform: rotate(180deg); }

.logout-link { 
    margin-top: auto; padding: 15px 25px; color: var(--danger); 
    text-decoration: none; font-weight: bold; 
    border-top: 1px solid rgba(255,255,255,0.1); transition: background 0.3s; 
}
.logout-link:hover { background: rgba(231, 76, 60, 0.1); }

/* --- 4. MAIN CONTENT AREA --- */
.main-content { 
    flex: 1; 
    height: 100vh; 
    overflow-y: auto; 
    overflow-x: hidden; 
    background: var(--bg-light);
    position: relative;
    max-width: calc(100vw - 260px);
}
.tab-panel { 
    display: none; 
    padding: 30px; 
    width: 100%; 
    animation: fadeIn 0.3s ease; 
}
.tab-panel.active { display: block; }
.pos-frame { width: 100%; height: calc(100vh - 60px); border: none; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); background: #fff; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- 5. OMNI DASHBOARD & FILTER BARS --- */
.filter-bar { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 20px; background: #fff; padding: 15px 20px; 
    border-radius: 8px; flex-wrap: wrap; gap: 15px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.filter-bar h2 { color: var(--primary-dark); font-size: 1.2rem; }
.filter-bar select { 
    padding: 8px 12px; border: 1px solid #ddd; border-radius: 5px; 
    background: #fdfbf7; font-weight: bold; color: var(--primary-dark); 
    font-size: 13px; cursor: pointer; outline: none;
}
.btn-action-group { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-refresh { background: var(--info); color: #fff; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold; font-size: 13px; transition: 0.3s; }
.btn-refresh:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-report { background: var(--success); color: #fff; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold; font-size: 13px; transition: 0.3s; }

.finance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.fin-card { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); border-top: 4px solid var(--primary-gold); }
.fin-card h3 { font-size: 12px; color: #666; text-transform: uppercase; margin-bottom: 10px; }
.fin-card .value { font-size: 24px; font-weight: bold; color: var(--primary-dark); word-wrap: break-word; }
.fin-card .sub-text { font-size: 11px; color: #888; margin-top: 5px; }

/* --- 6. CHARTS & GRAPHS --- */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.chart-container { background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); height: 350px; display: flex; flex-direction: column; }
.chart-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed var(--border-light); padding-bottom: 8px; margin-bottom: 10px; }
.chart-header h3 { font-size: 14px; color: var(--primary-dark); }
.chart-type-selector, .explorer-select { font-size: 12px; padding: 5px 8px; border-radius: 4px; border: 1px solid #ccc; background: #fdfbf7; cursor: pointer; font-weight: bold; outline: none;}
.chart-canvas-wrapper { flex-grow: 1; position: relative; height: 100%; width: 100%; }

/* --- 7. AI FORECASTS & CHAT GPT --- */
.ai-query-container { background: #fff; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); margin-bottom: 20px; border: 1px solid #e0e0e0; display: flex; flex-direction: column;}
.ai-query-header { background: linear-gradient(135deg, var(--primary-dark), #1a2a5c); color: #fff; padding: 12px 20px; font-family: 'Playfair Display', serif; font-size: 16px; display: flex; align-items: center; gap: 10px;}
.ai-query-chat { height: 200px; overflow-y: auto; padding: 15px; background: #fdfdfd; display: flex; flex-direction: column; gap: 10px; }
.ai-msg, .user-msg { padding: 10px 15px; border-radius: 8px; max-width: 85%; font-size: 13px; line-height: 1.5; word-wrap: break-word; }
.ai-msg { background: #f0f4f8; border-left: 3px solid var(--primary-gold); align-self: flex-start; color: #333; }
.user-msg { background: var(--primary-dark); color: #fff; align-self: flex-end; }
.ai-input-area { display: flex; border-top: 1px solid #eee; }
.ai-input-area input { flex: 1; padding: 15px; border: none; outline: none; font-size: 14px; }
.ai-input-area button { background: var(--primary-gold); color: var(--primary-dark); border: none; padding: 0 25px; font-size: 14px; cursor: pointer; font-weight: bold; transition: 0.2s; }
.ai-input-area button:hover { background: var(--primary-dark); color: #fff; }

.exec-report-container { background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); margin-bottom: 20px; font-size: 14px; line-height: 1.7; color: #444; border-top: 4px solid var(--primary-dark);}
.exec-report-container h3 { color: var(--primary-dark); font-family: 'Playfair Display', serif; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }

.ai-forecast-box { background: var(--primary-dark); color: #fff; padding: 25px; border-radius: 8px; margin-bottom: 20px;}
.ai-forecast-box h2 { color: var(--primary-gold); border-bottom: 1px solid rgba(197, 160, 89, 0.3); padding-bottom: 10px; font-size: 18px; margin-bottom: 15px;}
.forecast-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.tip-item { background: rgba(255,255,255,0.05); padding: 15px; border-left: 4px solid var(--success); border-radius: 4px; }
.tip-item.warning { border-left-color: var(--danger); }

/* --- 8. TABLES, CRM & DATA GRIDS --- */
.table-container { background: #fff; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); padding: 20px; width: 100%; margin-bottom: 20px; }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 15px; }
.table-header h2 { font-family: 'Playfair Display', serif; color: var(--primary-dark); font-size: 1.5rem; margin: 0;}
.table-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.table-actions input[type="text"] { padding: 8px 10px 8px 30px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; width: 220px; outline: none; }

.wide-table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid #eee; border-radius: 4px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #eee; font-size: 13px; color: #444; }
.data-table th { background: var(--primary-dark); color: #fff; white-space: nowrap; font-weight: bold; }
.data-table tr:hover { background-color: #f9f9f9; }

.truncate-text { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.status-badge { padding: 4px 10px; border-radius: 50px; font-size: 11px; font-weight: bold; display: inline-block; background: #e3f2fd; color: #1565c0; }
.chat-cell { max-width: 300px; white-space: pre-wrap; word-wrap: break-word; font-size: 12px; background: #f8f9fa; padding: 8px; border-radius: 4px; }

/* CRUD Action Buttons */
.btn-edit, .btn-delete, .btn-add, .btn-export, .btn-import { 
    border: none; border-radius: 4px; font-weight: bold; cursor: pointer; 
    font-size: 12px; transition: 0.3s; padding: 6px 12px; display: inline-flex; align-items: center; gap: 5px; 
}
.btn-edit { background: var(--primary-gold); color: #fff; }
.btn-delete { background: var(--danger); color: #fff; }
.btn-add { background: #3498db; color: #fff; padding: 8px 15px; }
.btn-export { background: var(--success); color: #fff; padding: 8px 15px; }
.btn-import { background: var(--info); color: #fff; padding: 8px 15px; }
.btn-edit:hover, .btn-delete:hover, .btn-add:hover, .btn-export:hover, .btn-import:hover { filter: brightness(0.9); }
.action-buttons { display: flex; gap: 5px; }

/* --- 9. MODALS & FORMS --- */
.edit-modal-overlay { 
    display: none; position: fixed; inset: 0; 
    background: rgba(10, 17, 40, 0.8); z-index: 9999; 
    justify-content: center; align-items: center; backdrop-filter: blur(4px); 
}
.edit-modal-overlay.active { display: flex; }
.edit-modal { 
    background: #fff; width: 90%; max-width: 500px; padding: 30px; 
    border-radius: 8px; box-shadow: 0 15px 40px rgba(0,0,0,0.2); 
    border-top: 5px solid var(--primary-gold); 
    max-height: 90vh; overflow-y: auto; 
}
.edit-modal h3 { color: var(--primary-dark); font-family: 'Playfair Display', serif; font-size: 1.4rem; margin-top: 0; margin-bottom: 15px; }
.edit-modal label { display: block; font-weight: bold; font-size: 0.85rem; color: #555; margin-top: 15px; }
.edit-modal input, .edit-modal select, .edit-modal textarea { 
    width: 100%; padding: 10px; margin-top: 5px; border: 1px solid #ccc; 
    border-radius: 4px; font-size: 0.95rem; font-family: 'Lato', sans-serif; outline: none;
}
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.modal-buttons { display: flex; gap: 15px; margin-top: 25px; }
.btn-save { flex: 1; background: var(--primary-gold); color: #fff; padding: 12px; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: 0.3s;}
.btn-cancel { flex: 1; background: #eee; color: #555; padding: 12px; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: 0.3s;}
.btn-save:hover { background: var(--primary-dark); }
.btn-cancel:hover { background: #ddd; }

/* --- 10. MEDIA UPLOADER --- */
.admin-box { background: #fff; max-width: 600px; margin: 0 auto; padding: 30px; border-top: 5px solid var(--primary-dark); border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.admin-box h2 { color: var(--primary-dark); font-family: 'Playfair Display', serif; border-bottom: 2px solid var(--primary-gold); padding-bottom: 10px; margin-top:0;}
.admin-box label { font-weight: bold; display: block; margin-top: 20px; color: #333; }
.admin-box input, .admin-box select { width: 100%; padding: 14px; margin: 8px 0 15px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 15px; }
.admin-box button { width: 100%; background: var(--primary-gold); color: var(--primary-dark); padding: 15px; border: none; font-weight: bold; font-size: 16px; margin-top: 10px; cursor: pointer; border-radius: 4px; transition: 0.3s;}
.admin-box button:hover { background: var(--primary-dark); color: #fff; }
.helper-text { font-size: 12px; color: #777; font-style: italic; margin-bottom: 8px; display: block; }
#previewImage { width: 100%; border-radius: 8px; margin-top: 15px; display: none; box-shadow: 0 4px 10px rgba(0,0,0,0.1);}

/* --- 11. STRICT RESPONSIVE ENGINE (MOBILE OPTIMIZATION) --- */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; }

@media (max-width: 1024px) {
    .chart-grid { grid-template-columns: 1fr; }
    .chart-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) { 
    body { flex-direction: column; }
    .mobile-topbar { display: flex; position: fixed; top: 0; }
    
    /* Off-Canvas Sidebar */
    .sidebar { position: fixed; top: 0; left: -260px; height: 100dvh; padding-bottom: 60px; z-index: 1001; transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1); }
    .sidebar.mobile-open { transform: translateX(260px); }
    .sidebar-overlay.active { display: block; }
    
    .main-content { 
        margin-top: 60px; 
        height: calc(100vh - 60px); 
        max-width: 100vw; 
    }
    
    .tab-panel { padding: 15px; }
    .pos-frame { height: calc(100vh - 90px); }
    
    .finance-grid { grid-template-columns: 1fr 1fr; }
    .chart-grid-3 { grid-template-columns: 1fr; } 
    .chart-container { height: 300px; }
    
    .filter-bar { flex-direction: column; align-items: stretch; }
    .btn-action-group { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
    
    .table-header { flex-direction: column; align-items: stretch; }
    .table-actions { justify-content: space-between; width: 100%; }
    .table-actions input[type="text"] { width: 100%; margin-bottom: 10px; }
    
    .grid-2-col { grid-template-columns: 1fr; gap: 0; }
    .edit-modal { padding: 20px; }
    .ai-input-area { flex-direction: column; }
    .ai-input-area button { padding: 15px; margin-top: 5px; }
}

@media (max-width: 480px) {
    .finance-grid { grid-template-columns: 1fr; }
    .btn-action-group { grid-template-columns: 1fr; }
}   