/**
 * AI Photo Trend - Responsive Styles
 * Mobile and tablet breakpoints - Comprehensive Revision
 */

/* ===== PERFORMANCE OPTIMIZATIONS (MOBILE) ===== */
* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    max-width: 100vw !important;
    position: relative;
}

/* Prevent swipe gestures from opening menu */
body {
    touch-action: pan-y; /* Only allow vertical scrolling */
    -webkit-user-drag: none;
    overscroll-behavior-x: none; /* Prevent bounce on horizontal */
}

/* Disable expensive effects on mobile */
@media (max-width: 767px) {
    /* Remove backdrop-filter on mobile (performance killer) */
    *,
    *::before,
    *::after {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Exception: Keep backdrop-filter for nav overlay (visual importance) */
    .nav-overlay {
        backdrop-filter: blur(3px) !important;
        -webkit-backdrop-filter: blur(3px) !important;
    }
    
    /* Reduce blur effects */
    .navbar,
    .auth-box,
    .bottom-nav {
        background: rgba(20, 20, 31, 0.98) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Reduce box-shadow complexity */
    .navbar {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* Disable expensive animations on input focus */
    input:focus,
    textarea:focus,
    select:focus {
        transform: none !important;
        will-change: auto !important;
    }
    
    /* Simplify transitions */
    * {
        transition-duration: 0.15s !important;
        transition-timing-function: ease-out !important;
    }
    
    /* Disable cosmic orb animations on mobile */
    .cosmic-orb {
        animation: none !important;
        opacity: 0.1 !important;
        filter: blur(40px) !important;
    }
    
    /* Optimize form inputs */
    input,
    textarea,
    select {
        will-change: auto;
        transform: translateZ(0);
    }
    
    /* Reduce repaints */
    .auth-box,
    .bottom-nav,
    .navbar {
        contain: layout style paint;
    }
}

@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .nav-link:active,
    .theme-card:active {
        transform: scale(0.98);
    }
}

/* ===== LARGE TABLETS & SMALL DESKTOPS ===== */
@media (max-width: 1024px) {
    .navbar {
        padding: 0.75rem 1.5rem;
    }
    
    .container {
        padding: 0 1.5rem;
    }
    
    .hero {
        padding: 3rem 1.5rem;
    }
    
    .themes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== TABLETS ===== */
@media (max-width: 768px) {
    /* Prevent page from shifting and horizontal overflow */
    .container,
    .nav-container,
    section,
    main,
    .hero,
    .landing-hero,
    .dashboard-hero,
    .themes-gallery-section,
    .gallery-section,
    .profile-hero,
    .plans-page-section,
    .contact-hero-section,
    .static-page-section,
    .admin-container,
    .admin-section {
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Prevent wide tables/cards from causing overflow */
    .admin-table,
    .table-responsive,
    .stats-grid,
    .plans-comparison-grid,
    .contact-info-grid {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Pricing grid should NOT have horizontal scroll */
    .pricing-grid,
    .themes-grid {
        max-width: 100%;
        overflow-x: visible; /* No horizontal scroll */
    }
    
    /* Typography */
    body {
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Layout */
    .container {
        padding: 0 1rem;
    }
    
    /* Navigation */
    .nav-container {
        padding: 0.75rem 1rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    .btn-large {
        padding: 0.85rem 1.75rem;
        font-size: 1rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
        min-height: 40px;
    }
    
    /* Hero Sections */
    .hero-content {
        padding: 0 1rem;
    }
    
    .hero-title {
        font-size: 1.6rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-title-landing {
        font-size: 2rem;
    }
    
    .hero-subtitle-landing {
        font-size: 1.1rem;
    }
    
    /* Stats */
    .stats-bar {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .stat-card {
        padding: 1.5rem;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    /* Grids */
    .themes-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .themes-grid-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .steps-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Generation Container */
    .generation-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .theme-gen-container {
        padding: 2rem 1rem;
    }
    
    /* Gallery */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Profile */
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Plans */
    .plans-comparison-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .plan-comparison-card {
        padding: 2rem 1.5rem;
    }
    
    .plan-price-main {
        font-size: 2rem;
    }
    
    .plan-price-original {
        font-size: 1.3rem;
    }
    
    /* FAQ */
    .faq-grid {
        grid-template-columns: 1fr;
    }
    
    /* Sections */
    .themes-section,
    .features-section,
    .how-section {
        padding: 3rem 1.5rem;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    /* Cards */
    .theme-card {
        margin-bottom: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    /* Modals */
    .modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-title {
        font-size: 1.5rem;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-table {
        font-size: 0.8rem;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Filter Bar */
    .filter-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-tabs {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .filter-tab {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 140px;
    }
    
    /* Action Buttons */
    .action-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: flex-start;
    }
    
    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    /* Auth Pages */
    .auth-box {
        padding: 2.5rem 2rem;
        width: 95%;
    }
    
    /* Upload Area */
    .upload-area {
        min-height: 250px;
    }
    
    /* Preview Section */
    .preview-section {
        min-height: 300px;
    }
}

/* ===== MOBILE PHONES ===== */
@media (max-width: 480px) {
    /* Typography */
    body {
        font-size: 0.85rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    /* Layout */
    .container {
        padding: 0 0.75rem;
    }
    
    /* Logo */
    .logo {
        font-size: 0.8rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
    
    .btn-large {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .btn-nav {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    /* Hero */
    .hero-title {
        font-size: 1.3rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
    
    .hero-title-landing {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    .hero-subtitle-landing {
        font-size: 0.95rem;
    }
    
    .hero-cta {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Stats */
    .stat-value {
        font-size: 1.75rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    /* Grids */
    .themes-grid,
    .themes-grid-dashboard {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    /* Cards */
    .theme-card {
        max-width: 100%;
    }
    
    .feature-card {
        padding: 1.25rem;
    }
    
    .plan-comparison-card {
        padding: 1.5rem 1.25rem;
    }
    
    /* Modals */
    .modal-content {
        padding: 1.5rem 1rem;
        width: 98%;
    }
    
    .modal-title {
        font-size: 1.25rem;
    }
    
    .modal-close {
        top: 1rem;
        right: 1rem;
        width: 32px;
        height: 32px;
    }
    
    /* Tables */
    .admin-table {
        font-size: 0.7rem;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Forms */
    .auth-box {
        padding: 2rem 1.5rem;
    }
    
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.75rem;
    }
    
    /* Section Padding */
    .themes-section,
    .features-section,
    .how-section {
        padding: 2.5rem 1rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .section-subtitle {
        font-size: 0.9rem;
    }
    
    /* Footer */
    .footer-landing {
        padding: 2rem 1rem;
    }
    
    /* Upload Area */
    .upload-area {
        min-height: 200px;
        padding: 1.5rem;
    }
    
    /* Theme Generation */
    .theme-gen-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .user-status {
        margin-left: auto;
        padding: 0.4rem 0.75rem;
        gap: 0.6rem;
    }
    
    .status-item svg {
        width: 14px;
        height: 14px;
    }
    
    .status-value {
        font-size: 0.85rem;
    }
    
    .status-divider {
        height: 16px;
    }
    
    .plan-badge {
        font-size: 0.65rem;
        padding: 0.3rem 0.6rem;
    }
    
    /* Info Boxes (Best Results Guide & Guarantee - Compact) */
    .info-box-guide,
    .info-box-guarantee {
        padding: 0.65rem 0.85rem !important;
        margin-bottom: 0.85rem !important;
        will-change: auto;
    }
    
    .info-box-guide h4,
    .info-box-guarantee strong {
        font-size: 0.8rem !important;
    }
    
    .info-box-guide ul {
        font-size: 0.75rem !important;
        padding-left: 0.85rem !important;
        line-height: 1.3 !important;
    }
    
    .info-box-guide svg,
    .info-box-guarantee svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    .info-box-guarantee p {
        font-size: 0.7rem !important;
        line-height: 1.35 !important;
    }
    
    .info-box-guarantee a {
        font-size: 0.7rem !important;
    }
    
    /* Bottom Nav Performance */
    .bottom-nav {
        will-change: transform;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        contain: layout style paint;
    }
    
    .bottom-nav-item {
        will-change: transform;
        transform: translateZ(0);
    }
    
    /* Profile Stats */
    .profile-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    /* Action Buttons */
    .btn-sm {
        padding: 0.45rem 0.75rem;
        font-size: 0.75rem;
        min-width: 36px;
    }
    
    .gallery-actions .btn-icon {
        width: 32px;
        height: 32px;
        padding: 0.3rem;
    }
    
    .gallery-actions .btn-icon svg {
        width: 14px;
        height: 14px;
    }
    
    /* Message Cards */
    .message-card {
        padding: 1.25rem;
    }
    
    .message-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .message-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ===== VERY SMALL DEVICES ===== */
@media (max-width: 320px) {
    .logo {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
    }
    
    .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.8rem;
    }
    
    .hero-title-landing {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
    
    .modal-content {
        padding: 1.25rem 0.85rem;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .landing-hero {
        min-height: auto;
        padding: 3rem 2rem;
    }
    
    .hero-stats {
        margin-top: 2rem;
    }
    
    .auth-container {
        padding: 2rem 1rem;
    }
}

/* ===== LOADING STATES ===== */
@media (max-width: 768px) {
    .loading-overlay {
        font-size: 0.9rem;
    }
    
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .navbar,
    .footer,
    .btn,
    .floating-cta,
    .nav-toggle,
    .nav-overlay {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a {
        text-decoration: underline;
    }
}

/* ===== SCROLLBAR MOBILE ===== */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-thumb {
        border-radius: 4px;
    }
}

/* ===== ACCESSIBILITY - REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}