/* ==========================================
   LAKHOKMAO - Global Styles
   ========================================== */

:root {
    --primary: #1E90FF;
    --primary-dark: #0066CC;
    --secondary: #FF6B35;
    --success: #25D366;
    --danger: #FF0000;
    --warning: #FFA500;
    --info: #00FFFF;
    --light: #F5F5F5;
    --dark: #1F2937;
    --border: #E5E7EB;
    --text-primary: #111827;
    --text-secondary: #6B7280;
}

/* ==========================================
   RESET & BASE STYLES
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: #FFFFFF;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #007BFF 0%, #00FFFF 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 127, 255, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #E55A1E;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #1FA854;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #CC0000;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   FORMS
   ========================================== */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

select.form-control {
    cursor: pointer;
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ==========================================
   CARDS & BOXES
   ========================================== */

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin: -1.5rem -1.5rem 1.5rem -1.5rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    margin: 1.5rem -1.5rem -1.5rem -1.5rem;
    background-color: var(--light);
}

/* ==========================================
   STATS CARDS
   ========================================== */

.stat-card {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card-label {
    font-size: 0.875rem;
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card-unit {
    font-size: 1rem;
    opacity: 0.8;
}

/* ==========================================
   TABLES
   ========================================== */

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table thead {
    background-color: var(--light);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background-color: rgba(30, 144, 255, 0.05);
}

.table-sm td,
.table-sm th {
    padding: 0.5rem;
}

/* ==========================================
   ALERTS
   ========================================== */

.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-info {
    background-color: #D1ECF1;
    color: #0C5460;
    border-color: #0C5460;
}

.alert-success {
    background-color: #D4EDDA;
    color: #155724;
    border-color: #155724;
}

.alert-danger {
    background-color: #F8D7DA;
    color: #721C24;
    border-color: #721C24;
}

.alert-warning {
    background-color: #FFF3CD;
    color: #856404;
    border-color: #856404;
}

.alert-close {
    float: right;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    opacity: 0.5;
}

.alert-close:hover {
    opacity: 1;
}

/* ==========================================
   MODALS
   ========================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    text-align: right;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================
   NAVBAR & NAVIGATION
   ========================================== */

/* User Panel Header (Mobile Only) */
.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--info) 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 999;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-logo {
    font-size: 1.25rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.balance-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Generic Navbar */
.navbar {
    background-color: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand img {
    height: 40px;
}

.navbar-menu {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.navbar-item {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.navbar-item:hover,
.navbar-item.active {
    color: var(--primary);
}

/* ==========================================
   SIDEBAR
   ========================================== */

.sidebar {
    background: var(--dark);
    color: white;
    padding: 2rem 0;
    width: 250px;
    min-height: 100vh;
    fixed: fixed;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-menu {
    list-style: none;
}

.sidebar-item {
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: white;
    background-color: rgba(30, 144, 255, 0.1);
    border-left: 3px solid var(--primary);
    padding-left: calc(1.5rem - 3px);
}

.sidebar-icon {
    width: 20px;
    height: 20px;
}

/* ==========================================
   GRID & LAYOUT
   ========================================== */

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

/* Responsive container widths */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
        padding: 1.5rem;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
        padding: 2rem;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.row-2 {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

.col-1 { grid-column: 1; }
.col-2 { grid-column: 1 / 3; }
.col-3 { grid-column: 1 / 4; }

/* ==========================================
   UTILITIES
   ========================================== */

.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.justify-content-center {
    justify-content: center;
}

.align-items-center {
    align-items: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.m-0 { margin: 0; }
.m-1 { margin: 0.5rem; }
.m-2 { margin: 1rem; }
.m-3 { margin: 1.5rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

.bg-light { background-color: var(--light); }
.bg-primary { background-color: var(--primary); }
.bg-dark { background-color: var(--dark); }

.rounded { border-radius: 0.5rem; }
.rounded-lg { border-radius: 1rem; }

.shadow-sm { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.shadow { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.shadow-lg { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2); }

.hidden { display: none !important; }
.visible { display: block !important; }

/* ==========================================
   BASE RESPONSIVE RULES (All Devices)
   ========================================== */

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
}

/* Fluid images */
img, .logo, .user-avatar, .profile-pic {
    max-width: 100%;
    height: auto;
}

/* Base grid system */
.grid-1 { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Mobile-first grids (single column default) */
.stats-grid,
.tasks-container,
.plan-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* ==========================================
   MOBILE FIRST (< 576px) - DEFAULT
   ========================================== */

/* Bottom Navigation - Mobile Default */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
}

.bottom-nav .nav-item.active {
    color: var(--primary);
}

.bottom-nav .nav-icon {
    font-size: 1.25rem;
}

/* Top Navigation - Hidden on Mobile */
.top-nav {
    display: none;
}

/* Add padding to body to account for fixed bottom nav */
body {
    padding-bottom: 70px;
}

/* ==========================================
   TABLET (576px to 992px)
   ========================================== */

@media (min-width: 576px) {
    /* Typography adjustments */
    h1 { font-size: 2.25rem; }
    h2 { font-size: 1.75rem; }
    
    /* 2-Column Grid for cards */
    .stats-grid,
    .tasks-container,
    .plan-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    /* Forms stay single column but better spacing */
    .form-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Cards get better padding */
    .card {
        padding: 2rem;
    }
    
    /* Modal gets better sizing */
    .modal-content {
        width: 80%;
        max-width: 600px;
    }
    
    /* Admin sidebar starts to show */
    .admin-layout {
        display: flex;
    }
    
    .admin-sidebar {
        width: 250px;
        position: sticky;
        top: 0;
        height: 100vh;
    }
    
    .admin-content {
        flex: 1;
        padding: 2rem;
    }
}

/* ==========================================
   DESKTOP/LAPTOP (> 992px)
   ========================================== */

@media (min-width: 992px) {
    /* CRITICAL: Hide bottom nav and mobile header, show top nav */
    .bottom-nav {
        display: none !important;
    }
    
    .user-header {
        display: none !important;
    }
    
    .top-nav {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--border);
        padding: 1rem 2rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        align-items: center;
        justify-content: space-between;
    }
    
    .top-nav-brand {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary);
    }
    
    .top-nav-menu {
        display: flex;
        gap: 2rem;
        align-items: center;
    }
    
    .top-nav-menu .nav-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        color: var(--text-primary);
        font-weight: 500;
        border-radius: 0.5rem;
        transition: all 0.3s ease;
    }
    
    .top-nav-menu .nav-item:hover {
        background: var(--light);
        color: var(--primary);
    }
    
    .top-nav-menu .nav-item.active {
        background: linear-gradient(135deg, var(--primary), var(--info));
        color: white;
    }
    
    /* Add padding to body for fixed top nav */
    body {
        padding-top: 70px;
        padding-bottom: 0;
    }
    
    /* 4-Column Grid for stats */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* 2-Column Grid for forms/content */
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    /* 3-Column Grid for plans/cards */
    .plan-grid,
    .tasks-container {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Full-width admin sidebar */
    .admin-sidebar {
        width: 250px;
        background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
        color: white;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        overflow-y: auto;
        padding: 2rem 1rem;
    }
    
    .admin-content {
        margin-left: 250px;
        padding: 2rem 3rem;
    }
    
    /* Header improvements */
    .header {
        padding: 1.5rem 2rem;
    }
    
    .container {
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 2rem;
    }
    
    /* Typography gets bigger */
    h1 { font-size: 2.75rem; }
    h2 { font-size: 2.25rem; }
    
    /* Better table spacing */
    .table th,
    .table td {
        padding: 1rem 1.5rem;
    }
}

/* ==========================================
   EXTRA LARGE SCREENS (> 1400px)
   ========================================== */

@media (min-width: 1400px) {
    .container {
        max-width: 1600px;
    }
    
    /* 4-Column everywhere */
    .plan-grid,
    .tasks-container {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Even better spacing */
    .admin-content {
        padding: 3rem 4rem;
    }
}

/* ==========================================
   MOBILE LANDSCAPE (Height < 500px)
   ========================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .bottom-nav {
        padding: 0.5rem 0;
    }
    
    .bottom-nav .nav-item {
        font-size: 0.7rem;
        padding: 0.25rem;
    }
    
    .bottom-nav .nav-icon {
        font-size: 1rem;
    }
}

/* ==========================================
   TABLET SPECIFIC (iPad, etc)
   ========================================== */

@media (min-width: 768px) and (max-width: 991px) {
    /* Hybrid mode: Show condensed top nav, hide mobile elements */
    .bottom-nav {
        display: none;
    }
    
    .user-header {
        display: none;
    }
    
    .top-nav {
        display: flex;
        padding: 1rem;
    }
    
    .top-nav-menu {
        gap: 1rem;
    }
    
    .top-nav-menu .nav-item {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    body {
        padding-top: 60px;
        padding-bottom: 0;
    }
    
    /* 3-Column grid on tablets */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .plan-grid,
    .tasks-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */

@media print {
    .navbar, .sidebar, .modal, .bottom-nav, .top-nav, .float-btn {
        display: none !important;
    }
    
    body {
        background: white;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
