/* =====================================================
   MOBILE RESPONSIVE STYLES
   HisabDesk+ Mobile-First Design
   ===================================================== */

/* =========================================
   0. Disable Tap Highlight & Drag (Android)
   ========================================= */
.bottom-nav,
.bottom-nav a,
.bottom-nav-item,
.mobile-header-container,
.mobile-header-container a,
.mobile-header-container button,
.mobile-menu-toggle {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* =========================================
   1. Bottom Navigation Bar
   ========================================= */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(20, 20, 28, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    transition: all 0.25s ease;
    padding: 5px 10px;
    gap: 3px;
}

.bottom-nav-item i {
    font-size: 1.2rem;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bottom-nav-item.active {
    color: #818cf8;
}

.bottom-nav-item.active i {
    transform: translateY(-2px) scale(1.1);
}

/* =========================================
   Central Plus Button (Premium Floating Design)
   ========================================= */
.bottom-nav-add {
    position: relative;
    top: -22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    z-index: 10001;

    /* Premium Gradient */
    background: linear-gradient(145deg, #8b5cf6, #6366f1, #3b82f6);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;

    /* Glow Effect */
    box-shadow:
        0 4px 15px rgba(99, 102, 241, 0.4),
        0 8px 30px rgba(139, 92, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);

    /* Border cutout */
    border: 3px solid #14141c;

    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@keyframes gradientShift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.bottom-nav-add i {
    font-size: 1.5rem;
    font-weight: 300;
}

.bottom-nav-add:active {
    transform: scale(0.92);
    box-shadow:
        0 2px 10px rgba(99, 102, 241, 0.5),
        0 4px 20px rgba(139, 92, 246, 0.4);
}

/* =========================================
   2. Mobile Header
   ========================================= */
.mobile-header-container {
    display: none;
    /* Hidden on desktop */
}

/* =========================================
   3. AI Chat Full Screen (Mobile)
   ========================================= */
.ai-mobile-full {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
    z-index: 100000 !important;
    background: #14141c !important;
}

.ai-mobile-full .chat-header {
    padding: 20px !important;
    padding-top: max(20px, env(safe-area-inset-top)) !important;
}

.ai-mobile-full .chat-body {
    height: calc(100% - 80px) !important;
    overflow-y: auto !important;
    padding: 20px !important;
}

/* =========================================
   4. Media Queries - Mobile (768px and below)
   ========================================= */
@media (max-width: 768px) {

    /* --- Hide Desktop Elements --- */
    .sidebar,
    .desktop-menu,
    .mobile-menu-toggle,
    .sidebar-overlay,
    .dashboard-header {
        display: none !important;
    }

    /* --- Show Mobile Elements --- */
    .bottom-nav {
        display: flex !important;
    }

    .mobile-header-container {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 15px 0;
        margin-bottom: 20px;
    }

    /* --- Main Content Adjustments --- */
    .dashboard-layout,
    .dashboard-grid {
        display: block !important;
    }

    .main-content,
    .content-grid {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 15px !important;
        padding-bottom: 100px !important;
    }

    /* =========================================
       STATS GRID - CRITICAL LAYOUT
       মাসিক ব্যালেন্স = Full Width (Top)
       মোট আয় + মোট ব্যয় = Same Line (Below)
       ========================================= */
    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
    }

    /* Monthly Balance - Full Width */
    .stat-card.balance {
        grid-column: 1 / -1 !important;
        background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
        padding: 18px !important;
    }

    /* Balance amount and words - close spacing */
    .stat-card.balance .stat-info h2.balance-amount {
        font-size: 1.5rem;
        font-weight: 700;
        margin-bottom: 2px;
    }

    .stat-card.balance .balance-words {
        font-size: 0.7rem;
        opacity: 0.85;
        display: block;
        margin-top: 0;
    }

    /* Income & Expense - Side by Side */
    .stat-card {
        padding: 14px !important;
        position: relative;
        overflow: hidden;
    }

    .stat-card .stat-icon {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .stat-info h4 {
        font-size: 0.7rem;
        margin-bottom: 4px;
        opacity: 0.85;
    }

    .stat-info h2 {
        font-size: 1.1rem;
        font-weight: 700;
    }

    /* Responsive amounts - shrink if too large */
    .stat-info h2.amount-responsive {
        font-size: clamp(0.9rem, 4vw, 1.2rem);
        word-break: break-word;
        line-height: 1.2;
    }

    /* --- Cards --- */
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    /* --- Content Grid (Chart + Transactions) --- */
    .content-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Reorder: Transactions first (top), Chart second (bottom) */
    .content-grid>.card:first-child {
        order: 2;
        /* Chart moves to bottom */
    }

    .content-grid>.card:last-child {
        order: 1;
        /* Transactions moves to top */
    }

    #financeChart {
        min-height: 250px !important;
        max-height: 300px !important;
    }

    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .card-header h4 {
        font-size: 1rem;
    }

    .period-selector {
        width: 100% !important;
    }

    .transaction-list {
        max-height: 350px !important;
        overflow-y: auto !important;
    }

    .transaction-item {
        padding: 12px 0 !important;
    }

    .transaction-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.85rem !important;
    }

    .transaction-right {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 3px !important;
    }

    /* --- Tables --- */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* --- Transaction Modal Mobile Optimization --- */
    .modal {
        align-items: flex-start !important;
        padding-top: 20px !important;
        overflow-y: auto !important;
    }

    .modal-content {
        width: 95% !important;
        max-width: 400px !important;
        margin: 0 auto 150px auto !important;
        /* Extra bottom margin for keyboard */
        padding: 25px !important;
        border-radius: 20px !important;
        max-height: none !important;
    }

    /* --- Profile Form --- */
    .profile-form-grid {
        grid-template-columns: 1fr !important;
    }

    .profile-form-grid>div {
        border-left: none !important;
        padding-left: 0 !important;
    }
}

/* =========================================
   5. Small Screens (480px and below)
   ========================================= */
@media (max-width: 480px) {
    .auth-container {
        padding: 15px;
    }

    .auth-card {
        padding: 20px !important;
        margin: 10px !important;
    }

    .btn {
        padding: 12px 20px;
    }

    .stat-info h2 {
        font-size: 1.1rem;
    }

    .stat-info h4 {
        font-size: 0.7rem;
    }
}

/* =========================================
   6. Mobile Optimized Transaction Form Styles
   ========================================= */
.mobile-optimized-modal {
    background: #1e1e28 !important;
    border-radius: 20px !important;
    padding: 25px !important;
    width: 95% !important;
    max-width: 400px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.transaction-type-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
}

.type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.95rem;
}

.type-option input {
    display: none;
}

.type-option.expense.active {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.type-option.income.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.mobile-input {
    width: 100%;
    padding: 14px 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
}

.mobile-input.with-icon {
    padding-left: 45px;
}

.mobile-input:focus {
    border-color: #6366f1;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.btn-mobile-submit {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-mobile-submit:active {
    transform: scale(0.98);
}

/* =====================================================
   7. AUTHENTICATION PAGES - MOBILE RESPONSIVE
   Landing, Login, Register Pages
   ===================================================== */

/* =========================================
   7.1 Landing Page (index.php) Mobile
   ========================================= */
@media (max-width: 768px) {

    /* --- Navbar Mobile --- */
    .navbar {
        flex-wrap: wrap;
        gap: 15px;
        padding: 15px 0;
    }

    .navbar .nav-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    .navbar .logo {
        width: 100%;
        text-align: center;
        font-size: 1.6rem;
    }

    .navbar .nav-buttons .btn {
        flex: 1;
        min-width: 120px;
        max-width: 160px;
        text-align: center;
        padding: 12px 16px;
        font-size: 0.9rem;
    }

    /* --- Hero Section Mobile --- */
    .hero {
        min-height: 70vh;
        padding: 50px 20px;
    }

    .hero-title {
        font-size: 2.5rem !important;
        line-height: 1.25;
        margin-bottom: 15px;
    }

    .hero-subtitle {
        font-size: 1.15rem !important;
        padding: 0 5px;
        margin-bottom: 30px !important;
        line-height: 1.6;
    }

    .hero .btn {
        font-size: 1.2rem !important;
        padding: 18px 40px !important;
        width: 90%;
        max-width: 320px;
        border-radius: 14px;
    }

    /* --- Pricing Section Mobile --- */
    .pricing-section {
        padding: 50px 10px;
    }

    .pricing-section h2 {
        font-size: 1.8rem !important;
    }

    .pricing-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 0 5px;
    }

    .pricing-card {
        padding: 20px !important;
    }

    .price-tag {
        font-size: 2.2rem !important;
    }

    .feature-list li {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.2rem !important;
    }

    .hero-subtitle {
        font-size: 1.05rem !important;
    }

    .hero .btn {
        font-size: 1.1rem !important;
        padding: 16px 35px !important;
    }

    .navbar .nav-buttons .btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-width: 100px;
    }

    .pricing-card {
        padding: 18px !important;
    }

    .price-tag {
        font-size: 2rem !important;
    }
}

/* =========================================
   7.2 Auth Pages (Login/Register) Mobile
   ========================================= */

/* Close Button for Auth Pages - Minimal X */
.auth-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    z-index: 10;
}

.auth-close-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}

.auth-close-btn:active {
    transform: scale(0.9);
}

/* Ensure auth-card has relative positioning for close button */
.auth-card {
    position: relative;
}

@media (max-width: 768px) {

    /* --- Auth Container --- */
    .auth-container {
        padding: 20px 15px;
        min-height: 100vh;
        align-items: flex-start;
        padding-top: 40px;
    }

    /* --- Auth Card --- */
    .auth-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 25px 20px !important;
        margin: 0 !important;
        border-radius: 20px !important;
    }

    /* --- Auth Header --- */
    .auth-header {
        margin-bottom: 25px;
    }

    .auth-header .logo {
        font-size: 1.8rem;
    }

    .auth-header p {
        font-size: 0.95rem;
    }

    /* --- Form Controls --- */
    .auth-card .form-group {
        margin-bottom: 18px;
    }

    .auth-card .form-label {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .auth-card .form-control {
        padding: 14px 16px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        border-radius: 12px;
    }

    /* --- Buttons --- */
    .auth-card .btn {
        padding: 14px 20px;
        font-size: 1rem;
        border-radius: 12px;
    }

    .auth-card .btn-primary {
        box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
    }

    /* --- Social Login Buttons --- */
    .social-btn {
        padding: 14px 16px !important;
        font-size: 0.95rem;
        border-radius: 12px !important;
    }

    .social-btn .google-icon {
        width: 22px;
        height: 22px;
    }

    /* --- Telegram Widget Container --- */
    .auth-card>div:has(script[src*="telegram"]) {
        margin-top: 15px;
    }

    /* --- Divider --- */
    .divider {
        margin: 18px 0;
        font-size: 0.85rem;
    }

    /* --- Alerts --- */
    .alert {
        padding: 14px;
        font-size: 0.85rem;
        border-radius: 10px;
        line-height: 1.5;
    }

    /* --- Links --- */
    .auth-card a {
        font-size: 0.9rem;
    }

    /* --- Footer Links Section --- */
    .auth-card>div:last-child {
        margin-top: 20px;
    }

    .auth-card>div:last-child p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .auth-container {
        padding: 15px 10px;
        padding-top: 30px;
    }

    .auth-card {
        padding: 20px 15px !important;
        border-radius: 16px !important;
    }

    .auth-header .logo {
        font-size: 1.6rem;
    }

    .auth-header p {
        font-size: 0.85rem;
    }

    .auth-card .form-control {
        padding: 12px 14px;
    }

    .auth-card .btn {
        padding: 13px 18px;
        font-size: 0.95rem;
    }

    .social-btn {
        padding: 12px 14px !important;
        font-size: 0.9rem;
    }
}

/* =========================================
   7.3 Touch-Friendly Improvements
   ========================================= */
@media (max-width: 768px) {

    /* Minimum touch target sizes (48px recommended) */
    .auth-card .btn,
    .social-btn,
    .navbar .nav-buttons .btn {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Active states for touch feedback */
    .auth-card .btn:active,
    .social-btn:active,
    .navbar .nav-buttons .btn:active {
        transform: scale(0.97);
        opacity: 0.9;
    }

    /* Prevent text selection on buttons */
    .btn,
    .social-btn {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Better focus states for accessibility */
    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.15);
    }
}

/* =========================================
   7.4 Landscape Orientation Fixes
   ========================================= */
@media (max-height: 500px) and (orientation: landscape) {
    .auth-container {
        padding: 15px;
        align-items: center;
    }

    .auth-card {
        padding: 15px !important;
    }

    .auth-header {
        margin-bottom: 15px;
    }

    .auth-card .form-group {
        margin-bottom: 12px;
    }

    .hero {
        min-height: auto;
        padding: 30px 15px;
    }
}