@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #8B5CF6;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --success: #10B981;
    --success-bg: #D1FAE5;
    --danger: #EF4444;
    --danger-bg: #FEE2E2;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); display: flex; min-height: 100vh; }

.container { padding: 2rem 3rem; flex: 1; overflow-y: auto; }
h1, h2, h3, h4 { color: var(--text-main); font-weight: 600; }
p { color: var(--text-muted); }

.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(226, 232, 240, 0.8);
}
.card:hover { box-shadow: var(--shadow-md); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.75rem 1.5rem; border-radius: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; border: none; font-size: 0.875rem;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 15px rgba(79, 70, 229, 0.3); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.btn-outline:hover { background: #F1F5F9; }

.input-group { margin-bottom: 1.5rem; }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--text-main); }
.input-control {
    width: 100%; padding: 0.875rem 1rem; border: 1px solid var(--border); border-radius: 12px;
    font-size: 0.875rem; transition: border-color 0.2s, box-shadow 0.2s; background-color: #F8FAFC;
}
.input-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); background-color: white; }

.sidebar { width: 260px; background-color: var(--card-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 2rem 1.5rem; }
.logo { display: flex; align-items: center; gap: 0.75rem; font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin-bottom: 3rem; }
.logo-icon { width: 32px; height: 32px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; }
.nav-menu { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-item { display: flex; align-items: center; gap: 1rem; padding: 0.875rem 1rem; border-radius: 12px; color: var(--text-muted); text-decoration: none; font-weight: 500; transition: all 0.2s; cursor: pointer; }
.nav-item:hover { background-color: var(--bg-color); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; }
.user-profile { display: flex; align-items: center; gap: 1rem; background: white; padding: 0.5rem 1rem; border-radius: 99px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background-color: #E0E7FF; color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }

/* Dashboard Specifics */
.stat-card {
    background: var(--card-bg); border-radius: var(--radius); padding: 1.5rem;
    box-shadow: var(--shadow-sm); display: flex; flex-direction: column; position: relative;
    border: 1px solid rgba(226, 232, 240, 0.8);
}
.stat-card.highlight { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border: none; }
.stat-card.highlight * { color: white; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-main); margin: 0.5rem 0; }
.stat-label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.stat-badge {
    position: absolute; top: 1.5rem; right: 1.5rem; padding: 0.25rem 0.6rem;
    border-radius: 99px; font-size: 0.75rem; font-weight: 600;
}
.stat-badge.positive { background: #D1FAE5; color: #059669; }
.stat-badge.negative { background: #FEE2E2; color: #DC2626; }
.stat-badge.neutral { background: #F1F5F9; color: #475569; }

.chart-tabs {
    display: flex; gap: 0.5rem; margin-bottom: 1.5rem; background: white; padding: 0.5rem;
    border-radius: 16px; box-shadow: var(--shadow-sm); overflow-x: auto; border: 1px solid var(--border);
}
.chart-tab-btn {
    padding: 0.75rem 1.25rem; border-radius: 12px; border: none; background: transparent;
    color: var(--text-muted); font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.chart-tab-btn:hover { background: #F8FAFC; color: var(--text-main); }
.chart-tab-btn.active { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2); }
.chart-section { display: none; }
.chart-section.active { display: block; }
.chart-container { position: relative; height: 250px; width: 100%; margin-top: 1rem; }

.badge { padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

.auth-wrapper { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-color); }
.auth-card { background: white; padding: 3rem; border-radius: 24px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; border: 1px solid var(--border); }
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 { font-size: 1.875rem; color: var(--text-main); margin-bottom: 0.5rem; }

/* Main Tabs */
.main-tabs { display: flex; gap: 2rem; margin-bottom: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.main-tab-btn { background: none; border: none; font-size: 1rem; font-weight: 500; color: var(--text-muted); cursor: pointer; padding: 0.75rem 0; transition: color 0.2s; position: relative; }
.main-tab-btn::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px; background: transparent; transition: background 0.2s; }
.main-tab-btn.active { color: var(--primary); }
.main-tab-btn.active::after { background: var(--primary); }
.main-tab-content { display: none; }
.main-tab-content.active { display: block; }

.chat-box { border: 1px solid var(--border); border-radius: 16px; height: 500px; display: flex; flex-direction: column; background: white; overflow: hidden; box-shadow: var(--shadow-sm);}
.messages-area { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; background: #F8FAFC;}
.msg { max-width: 70%; padding: 0.75rem 1rem; border-radius: 16px; font-size: 0.875rem; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.msg.sent { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.msg.received { align-self: flex-start; background: white; border: 1px solid var(--border); border-bottom-left-radius: 4px; color: var(--text-main); }
.chat-input-area { padding: 1rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; background: white; }

/* Range inputs */
input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: var(--primary); cursor: pointer; margin-top: -6px; box-shadow: 0 0 0 4px rgba(79,70,229,0.1); }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: var(--border); border-radius: 2px; }

/* Custom Select Dropdown */
.custom-select-wrapper { position: relative; width: 100%; max-width: 400px; margin-bottom: 2rem; font-family: 'Inter', sans-serif; }
.custom-select { position: relative; display: flex; flex-direction: column; }
.custom-select__trigger { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; font-size: 1rem; font-weight: 500; color: var(--text-main); background: #ffffff; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: all 0.3s; }
.custom-select__trigger:hover { border-color: var(--primary); }
.custom-select.open .custom-select__trigger { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.custom-options { position: absolute; display: block; top: 100%; left: 0; right: 0; background: #ffffff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); margin-top: 0.5rem; opacity: 0; visibility: hidden; pointer-events: none; z-index: 10; max-height: 300px; overflow-y: auto; transition: all 0.3s; }
.custom-select.open .custom-options { opacity: 1; visibility: visible; pointer-events: all; }
.custom-option { position: relative; display: block; padding: 0.875rem 1.5rem; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.2s; border-bottom: 1px solid #f1f5f9; }
.custom-option:last-child { border-bottom: none; }
.custom-option:hover { background-color: var(--bg-color); color: var(--primary); }
.custom-option.selected { color: var(--primary); background-color: #EEF2FF; font-weight: 600; }
.arrow { position: relative; height: 10px; width: 10px; }
.arrow::before, .arrow::after { content: ''; position: absolute; bottom: 0px; width: 0.15rem; height: 100%; transition: all 0.3s; background-color: var(--text-muted); }
.arrow::before { left: -3px; transform: rotate(-45deg); }
.arrow::after { left: 3px; transform: rotate(45deg); }
.custom-select.open .arrow::before { left: -3px; transform: rotate(45deg); }
.custom-select.open .arrow::after { left: 3px; transform: rotate(-45deg); }

/* Responsive Design */
@media (max-width: 768px) {
    body { flex-direction: column; }
    
    .sidebar { width: 100%; flex-direction: column; padding: 1.5rem 1rem 1rem 1rem; border-right: none; border-bottom: 1px solid var(--border); }
    .logo { margin-bottom: 1.5rem; justify-content: center; }
    
    .nav-menu { flex-direction: row; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; width: 100%; }
    .nav-menu::-webkit-scrollbar { height: 4px; }
    .nav-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
    .nav-item { padding: 0.5rem 1rem; white-space: nowrap; }
    
    .container { padding: 1rem; }
    .header { flex-direction: column; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
    .header div { width: 100%; }
    .header button, .header .user-profile { align-self: flex-start; }
    
    .grid, .grid-2, .grid-3, .chakra-grid, .report-grid { grid-template-columns: 1fr !important; }
    div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    
    .main-tabs { gap: 1rem; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; width: 100%; }
    .main-tab-btn { white-space: nowrap; }
    
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.5rem; }
    
    .auth-card { padding: 2rem 1.5rem; border-radius: 16px; }
    
    .custom-select-wrapper { max-width: 100%; }
    
    .chart-container { height: 250px; }
}
