/* ===================================
   MOBILE RESPONSIVE STYLES FOR FINANCE OS
   =================================== */

/* Mobile First - Base styles for mobile devices */
@media (max-width: 768px) {

    /* ========== NAVBAR ========== */
    .navbar {
        padding: 10px 15px;
    }

    #logo {
        width: 150px !important;
        margin-top: 5px !important;
    }

    /* Navbar Toggler Icon */
    .navbar-toggler {
        border: 2px solid #10b981;
        padding: 8px 12px;
        border-radius: 6px;
        background: rgba(16, 185, 129, 0.1);
    }

    .navbar-toggler:focus {
        box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
    }

    .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%2310b981' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
        width: 24px;
        height: 24px;
    }

    .navbar-nav {
        background: var(--primary-blue);
        padding: 15px;
        margin-top: 10px;
        border-radius: 8px;
    }

    .navbar-nav .nav-item {
        margin: 5px 0;
    }

    .navbar-nav .nav-link {
        padding: 12px 15px !important;
        border-radius: 6px;
        display: block;
    }

    .navbar-nav .nav-link.active {
        background: rgba(248, 209, 2, 0.2);
    }

    /* ========== SIDEBAR ========== */
    .sidebar {
        position: fixed !important;
        left: -250px !important;
        top: 60px;
        width: 250px !important;
        height: calc(100vh - 60px);
        transition: left 0.3s ease;
        z-index: 1050;
        background: var(--primary-blue);
    }

    .sidebar.mobile-active {
        left: 0 !important;
    }

    /* Hide toggle button on mobile - we'll use hamburger */
    .sidebar-toggle-btn {
        display: none;
    }

    /* Mobile overlay when sidebar is open */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1049;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* ========== MAIN CONTENT ========== */
    .main_content {
        margin-left: 0 !important;
        padding: 15px !important;
        width: 100%;
    }

    .main-dashboard-content {
        height: auto !important;
    }

    /* ========== DASHBOARD HOME ========== */
    .dashboard-home-page h2 {
        font-size: 1.5rem;
    }

    /* Quick Actions - Stack on mobile */
    .dashboard-home-page .card-body .row.g-3 {
        gap: 10px;
    }

    .dashboard-home-page .card-body .row.g-3 .col-md-3 {
        width: 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .dashboard-home-page .card-body .row.g-3 .col-md-3 a {
        height: 50px !important;
        font-size: 0.875rem;
    }

    /* Summary Cards - 2 columns on mobile */
    .dashboard-home-page .row.mb-4 .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
        padding: 5px;
    }

    .stat-card h6 {
        font-size: 0.75rem !important;
    }

    .stat-card h3 {
        font-size: 1.25rem !important;
    }

    .stat-card small {
        font-size: 0.7rem;
    }

    /* Charts - Full width on mobile */
    .dashboard-home-page .col-md-8,
    .dashboard-home-page .col-md-6,
    .dashboard-home-page .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 15px;
    }

    /* Tables - Horizontal scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.8rem;
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 8px 5px;
        white-space: nowrap;
    }

    /* Cards spacing */
    .card {
        margin-bottom: 15px;
    }

    .card-header h5 {
        font-size: 1rem;
    }

    /* ========== FORMS ========== */
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 5px;
    }

    .form-control,
    .form-select {
        font-size: 0.875rem;
        padding: 10px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.875rem;
    }

    /* Form rows - stack on mobile */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3 {
        margin-bottom: 15px;
    }

    /* ========== MODALS ========== */
    .modal-dialog {
        margin: 10px;
    }

    .modal-content {
        border-radius: 8px;
    }

    /* ========== BUDGET ALERTS ========== */
    #budget-alert {
        font-size: 0.85rem;
    }

    #budget-alert .progress {
        height: 15px !important;
    }

    /* ========== REPORTS ========== */
    .reports-dashboard-page h2 {
        font-size: 1.5rem;
    }

    /* Period Selector Form */
    .reports-dashboard-page .card-body form .col-md-4,
    .reports-dashboard-page .card-body form .col-md-3,
    .reports-dashboard-page .card-body form .col-md-2 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 10px;
    }

    /* ========== CATEGORY BADGES ========== */
    .category-badge {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    /* ========== ACCOUNTS ========== */
    .account-card {
        margin-bottom: 15px;
    }

    /* ========== PROJECTS ========== */
    .project-card {
        margin-bottom: 15px;
    }

    /* ========== EXPENSES & INCOME ========== */
    .expense-item,
    .income-item {
        padding: 10px;
        margin-bottom: 10px;
    }

    /* Receipt Preview */
    #image-preview {
        max-width: 100%;
    }

    #preview-img {
        max-width: 100%;
        height: auto;
    }

    /* ========== CHARTS ========== */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* ========== BUTTONS ========== */
    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        border-radius: 4px !important;
        margin-bottom: 5px;
    }

    /* Action buttons */
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .d-flex.justify-content-between > div {
        margin-top: 10px;
        width: 100%;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
        margin-bottom: 5px;
    }

    /* ========== PAGINATION ========== */
    .pagination {
        font-size: 0.875rem;
    }

    .pagination .page-link {
        padding: 5px 10px;
    }

    /* ========== ALERTS ========== */
    .alert {
        font-size: 0.875rem;
        padding: 10px;
    }

    /* ========== HIDE ON MOBILE ========== */
    .hide-mobile {
        display: none !important;
    }
}

/* Tablet Portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {

    .sidebar {
        width: 200px !important;
    }

    .main_content {
        margin-left: 200px !important;
    }

    .sidebar.collapsed {
        width: 60px !important;
    }

    .sidebar.collapsed ~ .main_content {
        margin-left: 60px !important;
    }

    /* Dashboard cards - 2 columns */
    .dashboard-home-page .row.mb-4 .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Charts */
    .dashboard-home-page .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .dashboard-home-page .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Large Mobile (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {

    /* Summary cards - 2 columns */
    .dashboard-home-page .row.mb-4 .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Quick actions - 2 columns */
    .dashboard-home-page .card-body .row.g-3 .col-md-3 {
        flex: 0 0 calc(50% - 5px);
        max-width: calc(50% - 5px);
    }
}

/* Extra Small Mobile (up to 575px) */
@media (max-width: 575px) {

    /* All cards full width */
    .card-body {
        padding: 15px;
    }

    /* Font sizes */
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h5 {
        font-size: 1rem;
    }

    /* Reduce padding */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

/* ========== MOBILE MENU TOGGLE BUTTON ========== */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: #10b981;
        color: white;
        border: none;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
        z-index: 1051;
        font-size: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s;
    }

    .mobile-menu-toggle:active {
        transform: scale(0.95);
    }

    .mobile-menu-toggle i {
        transition: transform 0.3s;
    }

    .mobile-menu-toggle.active i {
        transform: rotate(90deg);
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    .sidebar,
    .navbar,
    .mobile-menu-toggle,
    .sidebar-toggle-btn,
    .btn,
    .mobile-overlay {
        display: none !important;
    }

    .main_content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .card {
        page-break-inside: avoid;
    }
}
