/* --- Mobile Responsive Reset & Variables --- */
:root {
    --sidebar-width: 260px;
    --primary-color: #4f46e5;
    --bg-light: #f8fafc;
}

/* --- Media Queries for Mobile (Under 768px) --- */
@media (max-width: 768px) {
    /* --- Layout Adjustments --- */
    body.sidebar-open {
        overflow: hidden; /* Prevent scrolling when menu is open */
    }

    .main {
        transition: margin-left 0.3s ease;
        padding: 10px;
        width: 100%;
        box-sizing: border-box;
        margin-left: 0 !important;
        padding-top: 20px; /* Space for the floating hamburger (15px top + 50px height + 10px gap) */
    }

    body.dark-mode .main {
        background: #0d1117 !important;
    }

    body.dark-mode .sidebar {
        background: linear-gradient(180deg, #161b22 0%, #0d1117 100%) !important;
    }
    body.dark-mode .sidebar a {
        color: #8b949e !important;
    }
    body.dark-mode .sidebar h2 {
        color: #a78bfa !important;
    }

    /* --- Hamburger Menu Button --- */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--primary-color);
        border: none;
        border-radius: 8px;
        padding: 8px 10px;
        cursor: pointer;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .hamburger {
        width: 22px;
        height: 2px;
        background-color: white;
        margin: 4px 0;
        transition: 0.3s;
    }

    /* Dark mode mobile */
    body.dark-mode .mobile-menu-toggle {
        background: #7c6af7;
    }

    body.dark-mode .sidebar-overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    /* --- Sidebar Mobile States --- */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(var(--sidebar-width), 85vw);
        height: 100dvh;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar .sidebar-header {
        position: sticky;
        top: 0;
        z-index: 2;
        flex-shrink: 0;
    }

    .sidebar .sidebar-user {
        margin-top: auto;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 999;
    }

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

    /* --- Resource Tabs (Horizontal Scroll on Mobile) --- */
    .resource-tabs {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 8px !important;
        padding: 12px !important;
        margin-bottom: 20px;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .resource-tabs::-webkit-scrollbar {
        height: 6px;
    }

    .resource-tabs::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 10px;
    }

    .resource-tabs::-webkit-scrollbar-thumb {
        background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
        border-radius: 10px;
    }

    /* Show tab buttons with vertical layout on mobile */
    .tab-btn {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
        min-width: 70px !important;
        padding: 10px 12px !important;
        background: transparent;
        border: 2px solid transparent;
        color: #64748b;
        border-radius: 10px;
        cursor: pointer;
        font-weight: 600;
        transition: all 0.3s;
    }

    .tab-btn span:first-child {
        font-size: 20px;
    }

    .tab-btn span:last-child {
        font-size: 11px;
        white-space: nowrap;
    }

    .tab-btn:hover {
        background: #f8fafc;
        color: #3b82f6;
    }

    .tab-btn.active {
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        color: white;
        border-color: transparent;
        box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    }

    .tab-dropdown {
        display: none;
    }

    /* --- Responsive Grid --- */
    .resource-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); /* Stack on small screens */
        gap: 15px;
    }

    /* --- Modals (Full screen on mobile) --- */
    .modal-content {
        width: 95% !important;
        margin: 10px auto;
        padding: 20px;
        border-radius: 12px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .add-buttons-group {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .add-btn {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 12px 8px !important;
        white-space: normal !important;
        min-width: auto !important;
        width: 100% !important;
    }

    .add-btn .btn-icon {
        font-size: 28px !important;
    }

    .add-btn .btn-text {
        font-size: 12px !important;
        font-weight: 600 !important;
        text-align: center !important;
    }

    /* Adjust resource card styling for mobile */
    .resource-card {
        padding: 15px;
    }

    /* --- Statistics Page Mobile Styles --- */
    .page-header {
        padding: 25px 20px !important;
        margin-bottom: 20px !important;
    }

    .page-header h1 {
        font-size: 24px !important;
    }

    .subtitle {
        font-size: 14px !important;
        display: none !important;
    }

    .stats-overview {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .stat-card {
        padding: 20px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        text-align: left !important;
        gap: 15px !important;
    }

    .stat-icon {
        font-size: 32px !important;
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
        
    }

    .stat-value {
        font-size: 24px !important;
        margin-bottom: 0 !important;
    }

    .stat-label {
        font-size: 11px !important;
    }

    .section-header {
        text-align: left !important;
        margin-bottom: 20px !important;
    }

    .section-header h2 {
        font-size: 20px !important;
    }

    .section-header p {
        font-size: 13px !important;
    }

    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0px;

    }

    .modern-table {
        min-width: 600px !important;
        /* padding: 0px; */
    }

    .modern-table th,
    .modern-table td {
        padding: 10px !important;
        font-size: 12px !important;
    }

    .th-content {
        font-size: 11px !important;
        gap: 6px !important;
    }

    .th-icon {
        font-size: 14px !important;
    }

    .analytics-section {
        padding: 20px !important;
        margin-top: 20px !important;
    }
}

/* --- Media Queries for very small screens (Under 480px) --- */
@media (max-width: 480px) {
    .add-buttons-group {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .add-btn {
        padding: 10px 6px !important;
    }

    .add-btn .btn-icon {
        font-size: 24px !important;
    }

    .add-btn .btn-text {
        font-size: 11px !important;
    }
}

/* ── Profile Page Mobile ── */
@media (max-width: 768px) {
    /* Fix: body/main locked to 100vh with overflow:hidden in style.css — override here */
    body {
        height: auto !important;
        min-height: 100dvh !important;
        overflow: visible !important;
    }

    .main {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: visible !important;
        padding: 12px !important;
        padding-top: 16px !important;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        margin-left: 0 !important;
    }

    .profile-container {
        padding: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .profile-page-header {
        display: none !important;
        padding: 25px 20px !important;
        border-radius: 16px !important;
        margin-bottom: 20px !important;
    }

    .profile-page-header h1 {
        font-size: 22px !important;
        margin-bottom: 6px !important;
    }

    .profile-page-header p {
        font-size: 13px !important;
                display: none;
    }

    .profile-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        margin-bottom: 14px !important;
    }

    .profile-card {
        border-radius: 16px !important;
        padding: 18px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    .profile-avatar-large {
        width: 80px !important;
        height: 80px !important;
        font-size: 36px !important;
        margin-bottom: 12px !important;
    }

    .profile-name {
        font-size: 18px !important;
        margin-bottom: 4px !important;
    }

    .profile-email {
        font-size: 12px !important;
        margin-bottom: 14px !important;
    }

    .profile-actions {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        margin-top: 16px !important;
    }

    .action-btn {
        padding: 11px 8px !important;
        font-size: 13px !important;
        border-radius: 10px !important;
    }

    .profile-card h2 {
        font-size: 14.9px !important;
        margin-bottom: 12px !important;
        padding-bottom: 12px !important;
    }

    .detail-row {
        padding: 12px 0 !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }

    .detail-label {
        font-size: 11px !important;
        color: #94a3b8 !important;
    }

    .detail-value {
        font-size: 13px !important;
        word-break: break-all !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        margin-bottom: 14px !important;
    }

    .stat-card {
        padding: 12px 14px !important;
        gap: 12px !important;
        min-height: 64px !important;
        border-radius: 12px !important;
    }

    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
        border-radius: 9px !important;
        flex-shrink: 0 !important;
        margin-bottom: 0 !important;
    }

    .stat-content {
        flex: 1 !important;
        text-align: right !important;
    }

    .stat-value {
        font-size: 20px !important;
    }

    .stat-label {
        font-size: 9px !important;
    }

    .resource-item {
        padding: 12px 10px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .resource-info {
        gap: 10px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    .resource-type-icon {
        font-size: 24px !important;
        flex-shrink: 0 !important;
    }

    .resource-details h4 {
        font-size: 13px !important;
        margin-bottom: 3px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 180px !important;
    }

    .resource-details p {
        font-size: 11px !important;
    }

    .resource-price-tag {
        font-size: 12px !important;
        padding: 5px 12px !important;
    }

    /* Withdrawal info card — 2 cols on mobile */
    .wi-methods {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* Bottom cards — full width, proper spacing for nav bar */
    #withdrawalInfoCard,
    #recentResourcesCard {
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 12px !important;
    }

    /* Mobile header bar */
    .mobile-profile-header {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 480px) {
    .profile-page-header h1 {
        font-size: 18px !important;
    }

    .profile-actions {
        grid-template-columns: 1fr 1fr !important;
    }

    .detail-value {
        font-size: 12px !important;
    }

    .stat-value {
        font-size: 18px !important;
    }

    .resource-details h4 {
        max-width: 130px !important;
    }
}

/* ── Dark Mode Mobile Profile ── */
@media (max-width: 768px) {
    body.dark-mode .profile-page-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    }

    body.dark-mode .profile-card {
        background: #161b22 !important;
        border-color: #30363d !important;
    }

    body.dark-mode .profile-card h2 {
        color: #e6edf3 !important;
        border-bottom-color: #30363d !important;
    }

    body.dark-mode .profile-name {
        color: #e6edf3 !important;
    }

    body.dark-mode .profile-email {
        color: #8b949e !important;
    }

    body.dark-mode .detail-row {
        border-bottom-color: #30363d !important;
    }

    body.dark-mode .detail-label {
        color: #8b949e !important;
    }

    body.dark-mode .detail-value {
        color: #e6edf3 !important;
    }

    body.dark-mode .action-btn {
        background: #1c2333 !important;
        border-color: #30363d !important;
        color: #e6edf3 !important;
    }

    body.dark-mode .stat-card {
        background: #161b22 !important;
        border-color: #30363d !important;
    }

    body.dark-mode .stat-value {
        color: #a78bfa !important;
    }

    body.dark-mode .resource-item {
        border-bottom-color: #30363d !important;
    }

    body.dark-mode .resource-item:hover {
        background: #1c2333 !important;
    }

    body.dark-mode .resource-details h4 {
        color: #e6edf3 !important;
    }

    body.dark-mode .resource-details p {
        color: #8b949e !important;
    }

    body.dark-mode .resource-price-tag {
        background: #1c2333 !important;
        color: #3fb950 !important;
    }

    body.dark-mode .mobile-profile-header {
        background: linear-gradient(135deg, #7c6af7, #5b4fcf) !important;
    }

    body.dark-mode .detail-label {
        color: #8b949e !important;
    }
}
