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

:root {
    /* Brand Colors */
    --primary: #2563EB; /* Premium Blue */
    --primary-light: #eff6ff;
    --primary-hover: #1d4ed8;
    
    /* Layout & Background */
    --bg-body: #F8FAFC; /* Light gray background for content */
    --bg-sidebar: #FFFFFF;
    --bg-surface: #FFFFFF;
    
    /* Text Colors */
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    /* Status Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* Borders & Shadows */
    --border: #E2E8F0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius: 12px;
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ================== APP SHELL ================== */

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

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.sidebar-brand i {
    font-size: 24px;
    color: var(--primary);
}

.sidebar-menu {
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-menu-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-menu-item:hover, .sidebar-menu-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-search {
    display: flex;
    align-items: center;
    background: var(--bg-body);
    padding: 8px 16px;
    border-radius: 20px;
    gap: 8px;
    color: var(--text-muted);
}
.topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    width: 250px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 20px;
}
.topbar-icon {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
}
.notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}
.user-info {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-weight: 600;
    font-size: 14px;
}
.user-role {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
}

.page-header {
    margin-bottom: 24px;
}
.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* ================== COMPONENTS ================== */

/* Dashboard Cards Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.dashboard-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

/* ================== MODAL & PROFILE ================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--bg-surface);
    padding: 32px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    position: relative;
}
.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
}
.modal-close:hover { color: var(--danger); }
.profile-preview {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center; justify-content: center;
    font-size: 32px; font-weight: bold;
    margin: 0 auto 16px auto;
    object-fit: cover;
}

/* ================== MOBILE RESPONSIVENESS ================== */
@media (max-width: 768px) {
    /* Sidebar becomes Bottom Bar */
    .sidebar {
        top: auto;
        bottom: 0;
        width: 100%;
        height: 65px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    .sidebar-brand { display: none; } /* Hide logo on mobile */
    .sidebar-menu {
        flex-direction: row;
        padding: 0;
        margin: 0;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        overflow-y: hidden;
        overflow-x: auto;
    }
    .sidebar-menu-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        font-size: 10px;
        border-radius: 0;
    }
    .sidebar-menu-item i {
        font-size: 20px;
    }
    
    /* Adjust Main Content */
    .main-wrapper {
        margin-left: 0;
        padding-bottom: 65px; /* space for bottom bar */
    }
    
    .topbar {
        padding: 0 16px;
    }
    .topbar-search {
        display: none; /* Hide search on small screens */
    }
    
    .content-area {
        padding: 16px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr; /* Single column */
    }
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 8px;
}

/* Eye-catching icon colors */
.icon-blue { background: #e0e7ff; color: #4338ca; }
.icon-green { background: #dcfce7; color: #15803d; }
.icon-orange { background: #ffedd5; color: #c2410c; }
.icon-purple { background: #f3e8ff; color: #7e22ce; }
.icon-red { background: #fee2e2; color: #b91c1c; }
.icon-teal { background: #ccfbf1; color: #0f766e; }
.icon-pink { background: #fce7f3; color: #be185d; }
.icon-gray { background: #f1f5f9; color: #475569; }

.card-title {
    font-size: 18px;
    font-weight: 600;
}

.card-desc {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}
.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover {
    background-color: #dc2626;
}

/* Legacy Layout for Login & Install (Centered Box) */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-body);
}
.auth-box {
    background: var(--bg-surface);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 450px;
}
.auth-box h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--primary);
}

/* ================== DATA SECTION & TABLES ================== */
.master-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}
.data-section {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.data-section h2 {
    font-size: 18px;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}
th, td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border);
}
th {
    background-color: var(--primary-light);
    font-weight: 600;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.badge {
    background-color: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-left: 8px;
}
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
