/* ====================================================================
   MOBILE.CSS - TỐI ƯU CHO DI ĐỘNG (PHIÊN BẢN FIXED)
   Thêm vào index.html: <link rel="stylesheet" href="mobile.css">
   ==================================================================== */

/* ============= BASE MOBILE OVERRIDES ============= */
@media (max-width: 768px) {
    
    /* CONTAINER & LAYOUT - ĐƠN GIẢN HÓA */
    body {
        padding: 0px !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .container {
        margin: 0 !important;
        border-radius: 12px !important;
        box-shadow: 0 8px 20px rgba(0,0,0,0.15) !important;
    }
    
    /* HEADER - GỌN GÀN HỚN */
    .header {
        padding: 18px 15px !important;
    }
    
    .header h1 {
        font-size: 1.7rem !important;
        margin-bottom: 6px !important;
    }
    
    .header p {
        font-size: 0.9rem !important;
    }
    
    /* TABS - DỌC NHƯ BAN ĐẦU */
    .tabs {
        flex-direction: column !important;
        background: #f8f9fa;
    }
    
    .tab {
        padding: 12px 15px !important;
        font-size: 0.9rem !important;
        font-weight: 600;
        border-bottom: 1px solid #dee2e6;
        border-radius: 0;
    }
    
    .tab:last-child {
        border-bottom: none;
    }
    
    .tab.active {
        background: white !important;
        color: #667eea !important;
        border-left: 4px solid #667eea;
    }
    
    /* TAB CONTENT */
    .tab-content {
        padding: 6px !important;
		padding-top: 20px !important;
    }
    
    .sheet-section {
        padding: 0px !important;
        margin-bottom: 12px !important;
        border-radius: 8px !important;
    }
    
    .sheet-title {
        font-size: 1.2rem !important;
        margin-bottom: 12px !important;
    }
}

/* ============= KPI CARDS - FORCE 2x2 GRID ============= */
@media (max-width: 768px) {
    .kpi-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-bottom: 15px !important;
    }
    
    .kpi-card {
        padding: 15px 10px !important;
        border-radius: 8px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .kpi-icon {
        font-size: 2rem !important;
        margin-bottom: 8px !important;
    }
    
    .kpi-value {
        font-size: 1.6rem !important;
        margin-bottom: 5px !important;
        font-weight: 700 !important;
    }
    
    .kpi-label {
        font-size: 0.8rem !important;
        line-height: 1.2;
        text-align: center !important;
    }
}

/* ============= WEEK CALENDAR - SỬA LỖI SCROLL ============= */
@media (max-width: 768px) {
    .week-calendar {
        margin: 12px 0 !important;
        padding: 12px !important;
        border-radius: 8px !important;
        overflow: visible !important;
    }
    
    .week-row {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 6px !important;
        padding-bottom: 5px;
    }
    
    .week-day {
        min-width: 70px !important;
        flex-shrink: 0 !important;
        padding: 8px 6px !important;
        min-height: 55px !important;
        border-radius: 6px !important;
        cursor: pointer;
    }
    
    .day-name {
        font-size: 0.6rem !important;
        margin-bottom: 2px !important;
        text-transform: uppercase;
    }
    
    .day-date {
        font-size: 0.95rem !important;
        margin-bottom: 2px !important;
        font-weight: 600;
    }
    
    .day-tasks {
        font-size: 0.55rem !important;
        line-height: 1;
    }
}

/* ============= TABLES - ẨN CỘT THÔNG MINH ============= */
@media (max-width: 768px) {
    .responsive-table {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 6px !important;
    }
    
    table {
        min-width: 500px !important;
        font-size: 0.8rem !important;
    }
    
    th {
        padding: 8px 6px !important;
        font-size: 0.75rem !important;
    }
    
    td {
        padding: 6px !important;
        font-size: 0.8rem !important;
    }
    
    /* ẨN CỘT DAILY TASKS */
    #dailyTasksTable th:nth-child(4),
    #dailyTasksTable td:nth-child(4),
    #dailyTasksTable th:nth-child(5),
    #dailyTasksTable td:nth-child(5) {
        display: none !important;
    }
    
    /* ẨN CỘT WEEKLY TASKS */
    #weeklyTasksTable th:nth-child(4),
    #weeklyTasksTable td:nth-child(4),
    #weeklyTasksTable th:nth-child(6),
    #weeklyTasksTable td:nth-child(6),
    #weeklyTasksTable th:nth-child(7),
    #weeklyTasksTable td:nth-child(7) {
        display: none !important;
    }
    
    /* ẨN CỘT MONTHLY */
    #monthlyFinanceTable th:nth-child(6),
    #monthlyFinanceTable td:nth-child(6),
    #monthlyFinanceTable th:nth-child(7),
    #monthlyFinanceTable td:nth-child(7) {
        display: none !important;
    }
}

/* ============= BUTTONS & FORMS ============= */
@media (max-width: 768px) {
    .input-group {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .btn {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
        margin: 4px 0 !important;
        border-radius: 6px !important;
    }
    
    .input-group input,
    .input-group select {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }
}

/* ============= WEEKLY TASKS FILTER ============= */
@media (max-width: 768px) {
    .weekly-tasks-header {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .filter-dropdown {
        padding: 10px 12px !important;
        font-size: 0.85rem !important;
    }
    
    .dropdown-menu {
        max-height: 250px !important;
    }
    
    .dropdown-item {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
    }
}

/* ============= MODALS - ĐƠN GIẢN HÓA ============= */
@media (max-width: 768px) {
    .modal-content {
        width: 92% !important;
        margin: 8% auto !important;
        padding: 16px !important;
        border-radius: 8px !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
    }
    
    .modal-header {
        padding: 12px 16px !important;
        margin: -16px -16px 16px -16px !important;
    }
    
    .modal-title {
        font-size: 1rem !important;
    }
    
    .modal-footer {
        padding: 12px 0 0 0 !important;
        margin: 16px -16px -16px -16px !important;
        flex-direction: column !important;
        gap: 6px !important;
    }
    
    .form-group {
        margin-bottom: 12px !important;
    }
    
    .form-group label {
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
    }
    
    /* CUSTOM DATE MODAL */
    .date-options {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .date-option {
        padding: 12px !important;
    }
}

/* ============= CHARTS ============= */
@media (max-width: 768px) {
    .chart-container {
        padding: 12px !important;
        height: 220px !important;
        margin-bottom: 15px !important;
    }
    
    .chart-container h3 {
        font-size: 1rem !important;
        margin-bottom: 10px !important;
    }
}

/* ============= STATUS SELECTS ============= */
@media (max-width: 768px) {
    .status-select,
    .priority-select {
        padding: 5px 8px !important;
        font-size: 0.75rem !important;
        min-width: 70px !important;
    }
    
    .task-type-weekly,
    .task-type-monthly {
        padding: 2px 5px !important;
        font-size: 0.65rem !important;
    }
}

/* ============= WEEKLY PROGRESS TAB ============= */
@media (max-width: 768px) {
    .day-row {
        grid-template-columns:  1fr 1fr 1fr !important;
        gap: 8px !important;
    }
    
    .day-card {
        padding: 10px !important;
        border-radius: 6px !important;
    }
}

/* ============= SMOOTH SCROLLING ============= */
@media (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .tabs,
    .week-row,
    .responsive-table {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs::-webkit-scrollbar,
    .week-row::-webkit-scrollbar,
    .responsive-table::-webkit-scrollbar {
        display: none;
    }
}

/* ============= LOADING STATES ============= */
@media (max-width: 768px) {
    .loading {
        padding: 12px !important;
        font-size: 0.85rem !important;
    }
    
    .error,
    .success {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
        margin: 6px 0 !important;
    }
}

/* ============= VERY SMALL SCREENS - VẪN GIỮ 2 CỘT ============= */
@media (max-width: 480px) {
    body {
        padding: 0px !important;
    }
    
    .header h1 {
        font-size: 1.5rem !important;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr 1fr !important; /* VẪN 2 CỘT */
        gap: 8px !important;
    }
    
    .kpi-card {
        padding: 12px 8px !important;
    }
    
    .kpi-icon {
        font-size: 1.8rem !important;
    }
    
    .kpi-value {
        font-size: 1.4rem !important;
    }
    
    .kpi-label {
        font-size: 0.75rem !important;
    }
    
    .week-day {
        min-width: 60px !important;
        min-height: 50px !important;
    }
    
    .day-date {
        font-size: 0.85rem !important;
    }
}

/* ============= LANDSCAPE MODE ============= */
@media (max-width: 768px) and (orientation: landscape) {
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .modal-content {
        margin: 3% auto !important;
        max-height: 94vh !important;
    }
}