/* Mobile-specific styles */
@media (max-width: 768px) {
    /* Hide desktop sidebar completely on mobile */
    .sidebar {
        display: none !important;
    }

    /* Adjust dashboard container for mobile */
    .dashboard-container {
        grid-template-columns: 1fr !important;
        height: 100vh;
        position: relative;
    }

    /* Main content adjustments */
    .main-content {
        height: 100vh; /* Remove padding-bottom that creates black box */
        overflow: hidden;
    }

    /* Top bar mobile adjustments */
    .top-bar {
        margin: 15px 15px 20px 15px;
        padding: 12px 20px;
        border-radius: 10px;
    }

    .page-title {
        font-size: 16px;
    }

    .user-info span {
        font-size: 12px;
    }

    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    /* Content area mobile adjustments */
    .content-area {
        margin: 0 15px 0 15px;
        height: calc(100vh - 165px);
        overflow-y: auto;
        padding-bottom: 85px; /* Space for bottom nav */
    }

    /* Stats grid mobile layout */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 15px;
    }

    .stat-card {
        padding: 20px 15px;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-title {
        font-size: 11px;
    }

    /* Content grid mobile layout */
    .content-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }

    /* Section cards mobile adjustments */
    .section-card {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    .section-title {
        font-size: 14px;
        margin-bottom: 15px;
    }

    /* Form adjustments */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .form-input, .form-select {
        padding: 14px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 8px;
    }

    .form-label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    /* Button adjustments */
    .btn {
        padding: 14px 18px;
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Table responsive */
    .data-table {
        font-size: 12px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
        min-width: 80px;
    }

    /* Search bar mobile */
    .search-bar {
        flex-direction: column;
        gap: 10px;
    }

    .search-input {
        min-width: auto;
        font-size: 16px;
        padding: 12px;
    }

    /* Action grid mobile */
    .action-grid {
        grid-template-columns: 1fr !important;
    }

    .action-btn {
        padding: 18px 15px;
        font-size: 14px;
    }

    /* Chart container mobile */
    .chart-container {
        height: 250px;
        margin: 15px 0;
    }

    /* Category breakdown mobile */
    #categoryBreakdown ul li {
        padding: 8px 0;
        border-bottom: 1px solid #27272a;
    }

    /* Report results mobile */
    #reportResult table {
        font-size: 11px;
        display: block;
        overflow-x: auto;
    }

    /* Settings form mobile specific */
    .form-group input[type="checkbox"] {
        transform: scale(0.8);
        margin-right: 8px !important;
        width: 12px;
        height: 12px;
    }

    /* Danger zone mobile */
    .btn-danger {
        width: 100%;
        margin: 5px 0;
        padding: 15px;
    }
}

/* Mobile Bottom Navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(17, 17, 19, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid #27272a;
    padding: 8px 0;
    z-index: 1000;
    height: 70px;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #9ca3af;
    transition: all 0.3s ease;
    padding: 5px 10px;
    border-radius: 8px;
    min-width: 60px;
    cursor: pointer;
}

.mobile-nav-item.active {
    color: #f9fafb;
    background: rgba(75, 85, 99, 0.3);
}

.mobile-nav-icon {
    font-size: 18px;
    margin-bottom: 2px;
}

.mobile-nav-text {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    letter-spacing: 0.3px;
}

/* Mobile-specific scrollbar */
@media (max-width: 768px) {
    .content-area::-webkit-scrollbar {
        width: 4px;
    }

    .content-area::-webkit-scrollbar-track {
        background: rgba(31, 41, 55, 0.2);
    }

    .content-area::-webkit-scrollbar-thumb {
        background: rgba(75, 85, 99, 0.4);
        border-radius: 2px;
    }
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .delete-btn {
        padding: 12px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Better touch targets for form elements */
    input[type="checkbox"] {
        min-width: 44px;
        min-height: 44px;
    }

    /* Improve select dropdowns on mobile */
    .form-select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 8px center;
        background-repeat: no-repeat;
        background-size: 16px;
        padding-right: 40px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .stat-card {
        padding: 15px 10px;
    }

    .stat-value {
        font-size: 18px;
    }

    .content-area {
        height: calc(100vh - 120px);
    }
}

/* Very small screens (< 375px) */
@media (max-width: 374px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .top-bar {
        padding: 10px 15px;
        margin: 10px;
    }

    .page-title {
        font-size: 14px;
    }

    .section-card {
        padding: 15px 10px;
    }

    .mobile-nav-text {
        font-size: 9px;
    }

    .mobile-nav-icon {
        font-size: 16px;
    }
}