/* Design System & Variables */
:root {
    /* Colors - Light Theme */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --bg-body: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-sidebar: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --income-bg: rgba(16, 185, 129, 0.1);
    --expense-bg: rgba(239, 68, 68, 0.1);
    --profit-bg: rgba(99, 102, 241, 0.1);
    --stock-bg: rgba(245, 158, 11, 0.1);
    
    /* Effects */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --glass-blur: blur(10px);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

.dark-theme {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --secondary: #94a3b8;
    --bg-body: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden;
    transition: var(--transition);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; outline: none; background: none; font-family: inherit; }
input, select, textarea { outline: none; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-main); border-radius: var(--radius-sm); padding: 8px 12px; }

/* Utilities */
.glass {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
}

.hidden { display: none !important; }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 0 16px;
}

.sidebar-nav ul li {
    margin-bottom: 8px;
}

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav ul li.active a,
.sidebar-nav ul li a:hover {
    background-color: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 16px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
}

.user-card img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

#logout-btn {
    color: var(--danger);
    font-size: 1.1rem;
    transition: var(--transition);
}

#logout-btn:hover { transform: scale(1.1); }

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 24px;
    overflow-y: auto;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.search-bar {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-bar i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding-left: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    transition: var(--transition);
    position: relative;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border: 2px solid var(--bg-body);
    border-radius: 50%;
}

.date-display {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Views Common */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.view-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-secondary:hover { background: var(--border); }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
}

.stat-icon.income { background: var(--income-bg); color: var(--success); }
.stat-icon.expense { background: var(--expense-bg); color: var(--danger); }
.stat-icon.profit { background: var(--profit-bg); color: var(--primary); }
.stat-icon.stock { background: var(--stock-bg); color: var(--warning); }

.stat-details h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-container {
    padding: 24px;
    border-radius: var(--radius-lg);
}

.chart-container h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Recent Grid */
.recent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.recent-card {
    padding: 24px;
    border-radius: var(--radius-lg);
}

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

.view-all {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

/* Tables */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

tr:last-child td { border-bottom: none; }

.badge-income { background: var(--income-bg); color: var(--success); padding: 4px 8px; border-radius: 6px; font-weight: 600; font-size: 0.8rem; }
.badge-expense { background: var(--expense-bg); color: var(--danger); padding: 4px 8px; border-radius: 6px; font-weight: 600; font-size: 0.8rem; }

/* Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    align-items: center;
}

.filter-bar .search-input { position: relative; flex: 1; min-width: 200px; }
.filter-bar .search-input i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-bar .search-input input { width: 100%; padding-left: 36px; border-radius: var(--radius-md); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.modal {
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 32px;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: var(--radius-lg);
    text-align: center;
    background: rgba(255, 255, 255, 0.1) !important;
    color: white;
}

.login-header { margin-bottom: 32px; }
.login-header .logo { justify-content: center; color: white; font-size: 2rem; margin-bottom: 16px; }
.login-header p { opacity: 0.8; }

.login-card form .input-group label { color: white; text-align: left; }
.login-card form input { background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.3); color: white; }
.login-card form input::placeholder { color: rgba(255,255,255,0.6); }

/* Animations */
@keyframes slideIn {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-up {
    animation: slideIn 0.5s ease-out forwards;
}

/* Low Stock List */
.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--expense-bg);
    margin-bottom: 10px;
}

.item-info h4 { font-size: 0.95rem; margin-bottom: 2px; }
.item-info span { font-size: 0.8rem; color: var(--text-muted); }
.stock-badge { background: var(--danger); color: white; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }

/* Responsive */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
    .recent-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        transition: 0.3s;
    }
    .sidebar.active { left: 0; }
    .main-content { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .mobile-only { display: block !important; }
}

.mobile-only { display: none; }

/* Notification Toast */
.notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out forwards;
    min-width: 300px;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--primary); }
