/* ========================================
   USER PANEL MOBILE STYLES - COMPREHENSIVE FIX
   ======================================== */

/* Mobile-specific CSS variables */
:root {
    --mobile-nav-height: 60px;
    --mobile-bg: rgba(0, 0, 0, 0.8);
    --mobile-overlay: rgba(0, 0, 0, 0.5);
    --mobile-menu-width: 280px;
}

/* ===== MOBILE HEADER FIXES ===== */

@media (max-width: 768px) {
    .user-header {
        height: 60px;
    }
    
    .user-header .navbar {
        padding: 0 1rem;
    }
    
    .user-header .navbar-brand {
        font-size: 1rem;
        gap: 8px;
    }
    
    .user-header .brand-icon {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
    
    .user-header .brand-text {
        font-size: 0.9rem;
    }
    
    .user-header .navbar-toggler {
        width: 32px;
        height: 32px;
        padding: 4px;
    }
    
    .user-header .navbar-toggler-icon {
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 576px) {
    .user-header .navbar {
        padding: 0 0.75rem;
    }
    
    .user-header .brand-text {
        font-size: 0.8rem;
    }
    
    .user-header .navbar-toggler {
        width: 28px;
        height: 28px;
    }
}

/* ===== MOBILE MENU ===== */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--mobile-overlay);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: var(--mobile-menu-width);
    height: 100vh;
    background: #ffffff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    transition: all 0.3s ease;
    overflow-y: auto;
}

.mobile-menu.show {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
}

.mobile-menu-header h5 {
    margin: 0;
    font-weight: 600;
    color: #1f2937;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mobile-menu-close:hover {
    color: #1f2937;
    background: #e5e7eb;
}

.mobile-menu-body {
    padding: 16px 0;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: #374151;
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-menu-item:hover {
    background: #f9fafb;
    color: #4a67ff;
}

.mobile-menu-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.mobile-menu-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

/* ===== MOBILE SIDEBAR FIXES ===== */

@media (max-width: 768px) {
    .user-sidebar {
        width: 100%;
        max-width: 320px;
        transform: translateX(-100%);
        z-index: 1040;
    }
    
    .user-sidebar.show {
        transform: translateX(0);
    }
    
    .user-sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .sidebar-header {
        padding: 20px;
    }
    
    .sidebar-brand-title {
        font-size: 1.1rem;
    }
    
    .sidebar-brand-subtitle {
        font-size: 0.7rem;
    }
    
    .sidebar-nav .nav-link {
        padding: 14px 20px;
    }
    
    .sidebar-user-info {
        padding: 16px 20px;
    }
}

@media (max-width: 576px) {
    .user-sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .sidebar-header {
        padding: 16px;
    }
    
    .sidebar-nav .nav-link {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .sidebar-user-info {
        padding: 12px 16px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .user-name {
        font-size: 0.9rem;
    }
    
    .user-email {
        font-size: 0.8rem;
    }
}

/* ===== MOBILE MAIN CONTENT FIXES ===== */

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        margin-top: 60px;
        padding: 16px;
    }
    
    .page-header {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .page-title {
        font-size: 1.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .page-title i {
        font-size: 1.5rem;
    }
    
    .card {
        margin-bottom: 16px;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 16px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 12px;
        margin-top: 60px;
    }
    
    .page-header {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .page-title i {
        font-size: 1.25rem;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 12px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }
}

/* ===== MOBILE BOTTOM NAVIGATION ===== */

.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }
    
    .main-content {
        padding-bottom: 80px;
    }
}

.mobile-bottom-nav .nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
}

.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 8px 4px;
    border-radius: 8px;
}

.mobile-bottom-nav .nav-link:hover,
.mobile-bottom-nav .nav-link.active {
    color: #4a67ff;
    background-color: rgba(74, 103, 255, 0.1);
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.25rem;
}

/* ===== MOBILE UTILITIES ===== */

@media (max-width: 768px) {
    .d-none {
        display: none !important;
    }
    
    .d-lg-none {
        display: block !important;
    }
    
    .d-lg-flex {
        display: none !important;
    }
}

/* ===== MOBILE SCROLLBAR ===== */

.mobile-menu::-webkit-scrollbar {
    width: 4px;
}

.mobile-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mobile-menu::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.mobile-menu::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== MOBILE ANIMATIONS ===== */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

.mobile-menu.show {
    animation: slideInRight 0.3s ease-out;
}

.mobile-menu:not(.show) {
    animation: slideOutRight 0.3s ease-out;
}

/* ===== MOBILE TOUCH IMPROVEMENTS ===== */

@media (hover: none) and (pointer: coarse) {
    .mobile-menu-item {
        min-height: 48px;
    }
    
    .mobile-menu-close {
        min-height: 44px;
        min-width: 44px;
    }
    
    .user-header .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Ensure all links are tappable */
    a, button, .btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile bottom nav links */
    .mobile-bottom-nav .nav-link {
        min-height: 60px;
        padding: 8px 4px;
    }
}

/* ===== ADDITIONAL MOBILE LINK FIXES ===== */
@media (max-width: 768px) {
    /* Ensure all buttons and links are easily tappable */
    a.btn,
    button.btn,
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Footer links */
    footer a {
        min-height: 44px;
        padding: 0.5rem;
        display: inline-flex;
        align-items: center;
    }
    
    /* Table links */
    .table-responsive a.btn {
        min-width: 60px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Card header links */
    .card-header a.btn {
        width: 100%;
        margin-top: 0.5rem;
    }
    
    /* Profile action buttons */
    .text-center .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Mobile menu items - ensure they're always tappable */
    .mobile-menu-item {
        min-height: 48px;
        padding: 1rem 1.25rem;
        -webkit-tap-highlight-color: rgba(74, 103, 255, 0.2);
    }
    
    /* Mobile bottom nav - ensure links are tappable */
    .mobile-bottom-nav .nav-link {
        min-height: 60px;
        padding: 0.5rem;
        -webkit-tap-highlight-color: rgba(74, 103, 255, 0.2);
    }
}
