/*
 * QuMUN Mobile Responsive Styles
 * 
 * Comprehensive mobile-first responsive design for all pages
 * Optimized for devices from 320px to 1920px
 * 
 * Breakpoints:
 * - Mobile: 320px - 767px
 * - Tablet: 768px - 1024px  
 * - Desktop: 1025px+
 */

/* =============================================================================
   BASE MOBILE STYLES
   ============================================================================= */

/* Prevent horizontal scrolling */
html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent menu open body scroll */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

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

/* Mobile Menu Button */
.mobile-menu-button {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
    position: relative;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Hamburger Animation */
.mobile-menu-button.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-button.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-button.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

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

/* Logo visibility control - Desktop first */
.mobile-logo {
    display: none !important;
}

.desktop-logo {
    display: block !important;
}

/* Mobile menu button hidden by default */
.mobile-menu-button {
    display: none !important;
}

/* Mobile menu overlay hidden by default */
.mobile-menu-overlay {
    display: none !important;
}

/* Ensure nav-links-container doesn't interfere on desktop */
.nav-links-container {
    display: contents;
}

/* =============================================================================
   MOBILE NAVIGATION RESPONSIVE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    /* Show mobile menu button */
    .mobile-menu-button {
        display: flex !important;
        order: 1;
    }
    
    /* Show mobile logo, hide desktop logo */
    .mobile-logo {
        display: block !important;
        order: 2;
        flex-grow: 1;
        text-align: center;
    }
    
    .desktop-logo {
        display: none !important;
    }
    
    /* Mobile menu overlay */
    .mobile-menu-overlay {
        display: block !important;
    }
    
    /* Reset navbar for mobile */
    .navbar {
        height: 70px !important;
        padding: 0.5rem 0 !important;
    }
    
    /* Mobile navigation layout */
    .nav-content {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0 1rem !important;
        max-width: 100% !important;
    }
    
    /* Mobile navigation links */
    .nav-links {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        width: 280px !important;
        height: 100vh !important;
        background: linear-gradient(135deg, #cea124 0%, #b3941f 100%) !important;
        z-index: 1000 !important;
        transition: right 0.3s ease !important;
        overflow-y: auto !important;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3) !important;
        display: block !important;
        gap: 0 !important;
        flex: none !important;
        justify-content: flex-start !important;
    }
    
    .nav-links.mobile-open {
        right: 0 !important;
    }
    
    .nav-links-container {
        display: flex !important;
        flex-direction: column !important;
        padding: 80px 0 20px 0 !important;
        height: 100% !important;
    }
    
    /* Reset desktop nav-link styles for mobile */
    .nav-links a,
    .nav-link {
        display: flex !important;
        align-items: center !important;
        padding: 15px 25px !important;
        color: white !important;
        text-decoration: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        transition: all 0.3s ease !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        border-radius: 0 !important;
        background: none !important;
        transform: none !important;
        gap: 12px !important;
    }
    
    .nav-links a:hover,
    .nav-link:hover {
        background: rgba(255, 255, 255, 0.1) !important;
        color: white !important;
        text-decoration: none !important;
        transform: none !important;
    }
    
    .nav-links a.active,
    .nav-link.active {
        background: rgba(255, 255, 255, 0.2) !important;
        border-left: 4px solid white !important;
    }
    
    .nav-links a i,
    .nav-link i {
        margin-right: 0 !important;
        font-size: 18px !important;
        width: 20px !important;
        text-align: center !important;
    }
    
    .nav-links a span,
    .nav-link span {
        flex-grow: 1 !important;
    }
}

/* Desktop user panel - ensure proper structure */
.user-panel-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.user-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: nowrap;
}

.user-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.delegate-info {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* =============================================================================
   USER PANEL MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .user-panel {
        padding: 8px 15px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        border-bottom: 1px solid #e0e0e0 !important;
        margin-top: 70px !important;
    }
    
    .user-panel-content {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    
    .user-identity {
        display: flex !important;
        flex-direction: column !important;
        gap: 5px !important;
        flex-grow: 1 !important;
        align-items: flex-start !important;
    }
    
    .user-name {
        font-size: 14px !important;
        color: var(--secondary-color) !important;
    }
    
    .name-text {
        margin-left: 5px !important;
    }
    
    .role-badge {
        font-size: 12px !important;
        padding: 2px 8px !important;
        border-radius: 10px !important;
        align-self: flex-start !important;
    }
    
    .delegate-info {
        display: flex !important;
        gap: 8px !important;
        flex-wrap: wrap !important;
    }
    
    .delegate-badge,
    .committee-badge {
        font-size: 11px !important;
        padding: 2px 6px !important;
        border-radius: 8px !important;
    }
    
    .logout-button {
        padding: 6px 12px !important;
        font-size: 13px !important;
        border-radius: 15px !important;
        white-space: nowrap !important;
    }
    
    .logout-text {
        display: none !important;
    }
    
    .logout-button i {
        margin-right: 0 !important;
    }
}

/* =============================================================================
   CONTENT AREA MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .content {
        padding: 15px !important;
        margin-top: 0;
    }
    
    /* Flash messages */
    .flash-message {
        margin: 10px 0 !important;
        padding: 10px 15px !important;
        font-size: 14px !important;
        border-radius: 8px;
    }
}

/* =============================================================================
   FORM MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    /* Generic form improvements */
    .form-group {
        margin-bottom: 20px !important;
    }
    
    .form-group label {
        font-size: 14px !important;
        margin-bottom: 8px !important;
        display: block;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        width: 100% !important;
        padding: 12px 15px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border-radius: 8px !important;
        border: 1px solid #ddd !important;
        box-sizing: border-box;
        -webkit-appearance: none;
    }
    
    textarea {
        min-height: 100px !important;
        resize: vertical;
    }
    
    /* Button improvements */
    .btn,
    button {
        width: 100% !important;
        padding: 12px 20px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
        margin-bottom: 10px;
        touch-action: manipulation; /* Prevents double-tap zoom */
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 0;
    }
}

/* =============================================================================
   TABLE MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .table-responsive {
        border: none;
        margin-bottom: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 12px !important;
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 8px 4px !important;
        white-space: nowrap;
    }
    
    /* Stack table alternative for very small screens */
    .table-stack {
        display: none;
    }
}

@media (max-width: 480px) {
    .table-responsive {
        display: none;
    }
    
    .table-stack {
        display: block;
    }
    
    .table-stack-item {
        background: white;
        margin-bottom: 15px;
        padding: 15px;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-left: 4px solid var(--primary-color);
    }
    
    .table-stack-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .table-stack-row:last-child {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    .table-stack-label {
        font-weight: 600;
        color: var(--secondary-color);
        flex: 0 0 40%;
    }
    
    .table-stack-value {
        text-align: right;
        flex: 1;
    }
}

/* =============================================================================
   CARD MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .card,
    .admin-card,
    .chair-card {
        margin-bottom: 15px !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    .card-title {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }
    
    .card-text {
        font-size: 14px !important;
        line-height: 1.5;
    }
    
    /* Grid layouts */
    .admin-grid,
    .stats-grid,
    .action-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
}

/* =============================================================================
   MODAL MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }
    
    .modal-content {
        border-radius: 12px !important;
    }
    
    .modal-header {
        padding: 15px !important;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .modal-title {
        font-size: 18px !important;
    }
    
    .modal-body {
        padding: 20px 15px !important;
    }
    
    .modal-footer {
        padding: 15px !important;
        border-top: 1px solid #e0e0e0;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

/* =============================================================================
   HOMEPAGE MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .homepage-hero {
        height: 60vh !important;
        min-height: 400px;
    }
    
    .hero-background img {
        object-fit: cover;
        object-position: center;
    }
    
    .content-section {
        padding: 20px 15px !important;
    }
    
    .parent {
        display: flex !important;
        flex-direction: column !important;
        gap: 30px;
    }
    
    .div1,
    .div2 {
        width: 100% !important;
    }
    
    .div2 img {
        width: 100% !important;
        height: auto !important;
        max-height: 250px;
        object-fit: cover;
        border-radius: 12px;
    }
    
    #welcome-text {
        font-size: 24px !important;
        margin-bottom: 20px;
    }
    
    #home-text {
        font-size: 16px !important;
        line-height: 1.6;
        margin-bottom: 15px;
    }
}

/* =============================================================================
   CONFERENCE PAGE MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .dashboard-section {
        padding: 15px !important;
        margin: 0 0 20px 0 !important;
        width: 100% !important;
    }
    
    .schedule-section,
    .resolutions-section,
    .submit-resolution,
    .admin-section,
    .amendments-section {
        margin: 0 0 20px 0 !important;
        padding: 20px 15px !important;
        width: 100% !important;
        border-radius: 12px !important;
    }
    
    .section-title h3 {
        font-size: 20px !important;
        margin-bottom: 15px;
    }
    
    /* Resolution form */
    .resolution-form {
        width: 100% !important;
        margin-top: 15px !important;
    }
    
    /* TinyMCE editor mobile */
    .mce-tinymce {
        width: 100% !important;
    }
    
    .mce-container {
        border-radius: 8px !important;
    }
}

/* =============================================================================
   ADMIN DASHBOARD MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .admin-dashboard,
    .chair-dashboard {
        min-height: auto;
    }
    
    .admin-header,
    .chair-header {
        padding: 20px 0 !important;
    }
    
    .admin-header-content,
    .chair-header-content {
        flex-direction: column !important;
        text-align: center;
        gap: 15px;
        padding: 0 15px !important;
    }
    
    .admin-main-title,
    .chair-main-title {
        font-size: 24px !important;
    }
    
    .admin-content,
    .chair-content {
        padding: 20px 15px !important;
    }
    
    .admin-section,
    .chair-section {
        margin-bottom: 25px !important;
    }
    
    .section-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
    
    /* Monitoring cards */
    .monitoring-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .monitoring-card {
        min-height: auto !important;
    }
    
    .memory-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .stat-item {
        padding: 15px 10px !important;
    }
    
    .stat-value {
        font-size: 20px !important;
    }
    
    .stat-label {
        font-size: 12px !important;
    }
}

/* =============================================================================
   CHAIR DASHBOARD SPECIFIC MOBILE STYLES
   ============================================================================= */

@media (max-width: 768px) {
    .debate-card {
        border-radius: 12px !important;
    }
    
    .debate-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
    
    .debate-meta {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .debate-info {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .debate-actions .debate-form {
        flex-direction: column !important;
        gap: 10px;
    }
    
    .amendments-grid {
        grid-template-columns: 1fr !important;
    }
    
    .amendment-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }
    
    .amendment-actions .amendment-form {
        flex-direction: column !important;
        gap: 10px;
    }
    
    .concluded-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px;
    }
    
    .concluded-meta {
        flex-direction: column !important;
        gap: 5px;
    }
}

/* =============================================================================
   UTILITY CLASSES FOR MOBILE
   ============================================================================= */

/* Hide on mobile */
@media (max-width: 768px) {
    .d-mobile-none {
        display: none !important;
    }
    
    .mobile-hidden {
        display: none !important;
    }
}

/* Show only on mobile */
.d-mobile-block {
    display: none !important;
}

@media (max-width: 768px) {
    .d-mobile-block {
        display: block !important;
    }
    
    .mobile-only {
        display: block !important;
    }
}

/* Mobile text utilities */
@media (max-width: 768px) {
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-text-left {
        text-align: left !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-no-margin {
        margin: 0 !important;
    }
    
    .mobile-small-padding {
        padding: 10px !important;
    }
}

/* =============================================================================
   TOUCH OPTIMIZATIONS
   ============================================================================= */

/* Improve touch targets */
@media (hover: none) and (pointer: coarse) {
    .btn,
    button,
    .nav-link,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .card:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
}

/* =============================================================================
   LANDSCAPE MOBILE OPTIMIZATIONS
   ============================================================================= */

@media (max-width: 768px) and (orientation: landscape) {
    .homepage-hero {
        height: 80vh !important;
    }
    
    .admin-header,
    .chair-header {
        padding: 15px 0 !important;
    }
    
    .admin-main-title,
    .chair-main-title {
        font-size: 20px !important;
    }
    
    .user-panel {
        padding: 5px 15px !important;
    }
}

/* =============================================================================
   VERY SMALL SCREENS (iPhone SE, etc.)
   ============================================================================= */

@media (max-width: 480px) {
    .content {
        padding: 10px !important;
    }
    
    .admin-content,
    .chair-content {
        padding: 15px 10px !important;
    }
    
    .dashboard-section,
    .schedule-section,
    .resolutions-section,
    .admin-section,
    .amendments-section {
        padding: 15px 10px !important;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .user-identity {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .delegate-info {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .modal-dialog {
        margin: 5px !important;
        max-width: calc(100vw - 10px) !important;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .mobile-menu-button,
    .mobile-menu-overlay,
    .user-panel,
    .navbar,
    .logout-button {
        display: none !important;
    }
    
    .content {
        margin-top: 0 !important;
        padding: 0 !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}