/* ============================================
   style.css
   ============================================ */

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* ============================================
   MOBILE MENU BUTTON - HIGHEST PRIORITY
   ============================================ */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 9999 !important;
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto !important;
    user-select: none;
    -webkit-user-select: none;
}

.menu-toggle:active {
    transform: scale(0.95);
    background: var(--primary);
}

/* Hide menu button on login page */
#mainApp.page-hidden ~ .menu-toggle {
    display: none !important;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 250px;
    background: var(--primary);
    color: white;
    padding-top: 20px;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar .logo {
    text-align: center;
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.8);
    padding: 12px 25px;
    display: block;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    backdrop-filter: blur(2px);
}

/* Main Content */
.main-content {
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s ease;
}

.header {
    background: white;
    padding: 15px 30px;
    margin: -20px -20px 20px -20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

/* Dashboard Filters - Inline in Header */
.dashboard-filters {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
    flex-wrap: wrap;
}

.dashboard-filters select,
.dashboard-filters input {
    padding: 5px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
}

.dashboard-filters .btn {
    padding: 5px 15px;
    font-size: 14px;
}

.dashboard-filters .filter-group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dashboard-filters label {
    font-size: 13px;
    color: #6c757d;
    margin: 0;
    white-space: nowrap;
}

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary), var(--success));
}

.stat-card.card-primary::before {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stat-card.card-success::before {
    background: linear-gradient(90deg, var(--success), #2ecc71);
}

.stat-card.card-warning::before {
    background: linear-gradient(90deg, var(--warning), #f1c40f);
}

.stat-card.card-danger::before {
    background: linear-gradient(90deg, var(--danger), #c0392b);
}

.stat-card.card-info::before {
    background: linear-gradient(90deg, var(--info), #5dade2);
}

.stat-card .icon {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 32px;
    opacity: 0.15;
}

.stat-card .value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 3px;
    animation: countUp 1s ease-out;
}

.stat-card .label {
    color: #7f8c8d;
    font-size: 11px;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.schedule-table {
    font-size: 14px;
    min-width: 600px;
}

/* Badges */
.badge-pending { background: var(--warning); }
.badge-won { background: var(--success); }
.badge-lost { background: var(--danger); }
.badge-active { background: var(--success); }
.badge-paid { background: var(--success); }
.badge-partial { background: var(--warning); }

/* Modals */
.modal-header {
    background: var(--primary);
    color: white;
}

/* Notifications */
.notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 10px;
}

/* Login */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

/* Page Control */
.page-hidden {
    display: none !important;
}

/* Tabs */
.nav-tabs .nav-link {
    color: var(--primary);
}

.nav-tabs .nav-link.active {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

/* Charts */
.chart-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    animation: slideIn 0.6s ease-out;
    height: 280px;
    position: relative;
}

.chart-container h6 {
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 14px;
}

.chart-container canvas {
    max-height: 200px !important;
    width: 100% !important;
    height: 200px !important;
}

/* Forecast Chart */
.forecast-chart-container {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 15px;
    animation: slideIn 0.6s ease-out;
    height: 280px;
    position: relative;
}

.forecast-chart-container h6 {
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 14px;
}

.forecast-chart-container canvas {
    max-height: 200px !important;
    width: 100% !important;
    height: 200px !important;
}

/* Buttons */
.btn-primary {
    background: var(--secondary);
    border: none;
}

.btn-primary:hover {
    background: #2980b9;
}

/* Animations */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    
    /* Show menu toggle button */
    .menu-toggle {
        display: flex !important;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        z-index: 9999;
    }
    
    /* Show sidebar when active */
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    /* Show overlay when sidebar is active */
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Remove left margin from main content */
    .main-content {
        margin-left: 0;
        padding: 15px;
        padding-top: 75px; /* Space for fixed menu button */
    }
    
    /* Adjust header */
    .header {
        padding: 15px !important;
        margin: -60px -15px 15px -15px !important;
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px;
        position: relative;
        z-index: 1 !important;
    }
    
    .header > div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .header > div:first-child {
        align-items: flex-start;
    }
    
    .header > div:last-child {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .header h4 {
        margin: 0 !important;
        width: 100%;
    }
    
    /* Stack dashboard filters vertically */
    .dashboard-filters {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-left: 0 !important;
        margin-top: 10px;
        width: 100%;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 8px;
    }
    
    .dashboard-filters .filter-group {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    
    .dashboard-filters .filter-group label {
        min-width: 50px;
        flex-shrink: 0;
    }
    
    .dashboard-filters select,
    .dashboard-filters input {
        flex: 1;
        min-width: 0;
    }
    
    .dashboard-filters .btn {
        width: 100%;
        margin-top: 5px;
    }
    
    /* Stat cards - full width on mobile */
    .stat-card {
        margin-bottom: 10px;
    }
    
    .stat-card .value {
        font-size: 20px;
    }
    
    .stat-card .icon {
        font-size: 28px;
    }
    
    /* Table container - add horizontal scroll */
    .table-container {
        padding: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Charts - reduce height on mobile */
    .chart-container,
    .forecast-chart-container {
        height: auto;
        min-height: 250px;
    }
    
    .chart-container canvas,
    .forecast-chart-container canvas {
        max-height: 180px !important;
        height: 180px !important;
    }
    
    /* Login card */
    .login-card {
        padding: 30px 20px;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 10px;
    }
    
    /* Tabs */
    .nav-tabs {
        flex-wrap: wrap;
    }
    
    .nav-tabs .nav-link {
        font-size: 14px;
        padding: 8px 12px;
    }
}

/* Small mobile devices (480px) */
@media (max-width: 480px) {
    
    /* Further reduce padding */
    .main-content {
        padding: 10px;
        padding-top: 75px;
    }
    
    .header {
        padding: 10px !important;
        margin: -65px -10px 10px -10px !important;
    }
    
    .header h4 {
        font-size: 18px;
    }
    
    /* Stat cards - smaller text */
    .stat-card {
        padding: 12px 15px;
    }
    
    .stat-card .value {
        font-size: 18px;
    }
    
    .stat-card .label {
        font-size: 10px;
    }
    
    .stat-card .icon {
        font-size: 24px;
        right: 10px;
        top: 10px;
    }
    
    /* Table - smaller font */
    .schedule-table {
        font-size: 12px;
    }
    
    /* Buttons */
    .btn {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    /* Charts */
    .chart-container,
    .forecast-chart-container {
        padding: 10px;
        min-height: 220px;
    }
    
    .chart-container h6,
    .forecast-chart-container h6 {
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .chart-container canvas,
    .forecast-chart-container canvas {
        max-height: 160px !important;
        height: 160px !important;
    }
    
    /* Sidebar */
    .sidebar .logo {
        font-size: 20px;
        padding: 15px;
    }
    
    .sidebar .nav-link {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    /* Menu button - slightly smaller */
    .menu-toggle {
        width: 45px;
        height: 45px;
        font-size: 20px;
        top: 12px;
        left: 12px;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        overflow-y: auto;
    }
    
    .chart-container,
    .forecast-chart-container {
        height: auto;
        min-height: 200px;
    }
}