/* Responsive Design - Mobile First Approach */

/* Breakpoints */
/* Mobile: 320px - 767px */
/* Tablet: 768px - 1023px */
/* Desktop: 1024px+ */

/* Base Mobile Styles (320px+) */
@media (max-width: 767px) {
    /* Typography adjustments */
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
    
    /* Container adjustments */
    .container {
        padding: 0 var(--space-4);
    }
    
    .container-fluid {
        padding: 0 var(--space-4);
    }
    
    /* Header Mobile */
    .navbar {
        padding: var(--space-3) 0;
    }
    
    .nav-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        border-top: 1px solid var(--gray-200);
        flex-direction: column;
        gap: 0;
        padding: var(--space-4);
        box-shadow: var(--shadow-lg);
        transform: translateY(-100%);
        transition: transform var(--transition-normal);
        z-index: 1001;
    }
    
    .nav-menu.active {
        transform: translateY(-100%);
        top: 100%;
    }
    
    .nav-menu li {
        width: 100%;
    }
    
    .nav-link {
        display: block;
        padding: var(--space-3) 0;
        border-bottom: 1px solid var(--gray-100);
    }
    
    .nav-actions {
        flex-direction: column;
        gap: var(--space-2);
        align-items: stretch;
    }
    
    .cta-button {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-sm);
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Hero Section Mobile */
    .hero {
        padding: calc(60px + var(--space-12)) 0 var(--space-12);
        text-align: center;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }
    
    .hero-title {
        font-size: var(--text-3xl);
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: var(--text-lg);
        margin-bottom: var(--space-6);
    }
    
    .hero-visual {
        order: -1;
    }
    
    .demo-container {
        max-width: 300px;
    }
    
    .demo-content {
        grid-template-columns: 1fr;
        gap: var(--space-3);
        min-height: 200px;
    }
    
    .stats {
        justify-content: center;
        gap: var(--space-6);
    }
    
    /* Features Mobile */
    .features {
        padding: var(--space-12) 0;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .feature-card {
        padding: var(--space-6);
    }
    
    /* Templates Gallery Mobile */
    .templates-gallery {
        padding: var(--space-12) 0;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .template-preview {
        height: 300px;
        padding: var(--space-4);
    }
    
    /* Testimonials Mobile */
    .testimonials {
        padding: var(--space-12) 0;
    }
    
    .testimonials-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .testimonial-card {
        padding: var(--space-6);
    }
    
    /* CTA Mobile */
    .cta {
        padding: var(--space-12) 0;
    }
    
    .cta-content h2 {
        font-size: var(--text-2xl);
    }
    
    .cta-content p {
        font-size: var(--text-lg);
    }
    
    /* Footer Mobile */
    .footer {
        padding: var(--space-12) 0 var(--space-6);
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--space-8);
        text-align: center;
    }
    
    .footer-links {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }
    
    /* Generator Mobile */
    .generator-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    
    .form-panel {
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .preview-panel {
        min-height: 400px;
    }
    
    .tabs-nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-1);
    }
    
    .tab-btn {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-3);
    }
    
    .tab-btn span {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .header-content {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .header-center {
        margin: 0;
        max-width: none;
        width: 100%;
    }
    
    .header-right {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .cv-preview {
        width: 100%;
        min-height: 600px;
        transform: scale(0.8);
        transform-origin: top center;
    }
    
    .preview-container {
        padding: var(--space-4);
    }
    
    /* Modal Mobile */
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
        margin: var(--space-4);
    }
    
    .modal-body {
        padding: var(--space-4);
    }
    
    .templates-grid .template-card {
        margin-bottom: var(--space-4);
    }
}

/* Tablet Styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Header Tablet */
    .nav-menu {
        gap: var(--space-6);
    }
    
    .nav-actions {
        gap: var(--space-3);
    }
    
    /* Hero Tablet */
    .hero-content {
        gap: var(--space-12);
    }
    
    .hero-title {
        font-size: var(--text-4xl);
    }
    
    /* Features Tablet */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Templates Tablet */
    .templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Testimonials Tablet */
    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Generator Tablet */
    .generator-layout {
        grid-template-columns: 1fr 1fr;
    }
    
    .tabs-nav {
        display: flex;
        flex-wrap: wrap;
    }
    
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .cv-preview {
        transform: scale(0.9);
    }
}

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-title {
        font-size: 4rem;
    }
    
    .section-title {
        font-size: 3rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-10);
    }
    
    .templates-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-10);
    }
    
    .cv-preview {
        transform: scale(1.1);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 44px;
        padding: var(--space-3) var(--space-6);
    }
    
    .tab-btn {
        min-height: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Remove hover effects on touch devices */
    .feature-card:hover,
    .template-card:hover,
    .testimonial-card:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    /* Improve form inputs for touch */
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* High DPI / Retina Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders and shadows */
    .btn,
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-width: 0.5px;
    }
    
    .cv-preview {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Phone Orientation */
@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        padding: calc(60px + var(--space-8)) 0 var(--space-8);
    }
    
    .hero-content {
        gap: var(--space-6);
    }
    
    .generator-layout {
        grid-template-columns: 1fr 1fr;
    }
    
    .tabs-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tabs-nav::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Print Styles */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    .header,
    .footer,
    .nav-actions,
    .mobile-menu-toggle,
    .btn,
    .preview-header,
    .tabs-nav,
    .form-panel {
        display: none !important;
    }
    
    .generator-layout {
        grid-template-columns: 1fr !important;
    }
    
    .preview-panel {
        background: white !important;
    }
    
    .cv-preview {
        box-shadow: none !important;
        border-radius: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: none !important;
    }
    
    .preview-container {
        padding: 0 !important;
    }
    
    body {
        font-size: 12pt !important;
        line-height: 1.4 !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
    
    .experience-item,
    .education-item,
    .cv-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .animate__animated {
        animation: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --white: #1e293b;
        --gray-50: #0f172a;
        --gray-100: #1e293b;
        --gray-200: #334155;
        --gray-300: #475569;
        --gray-400: #64748b;
        --gray-500: #94a3b8;
        --gray-600: #cbd5e1;
        --gray-700: #e2e8f0;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
    }
    
    body {
        background-color: var(--gray-50);
        color: var(--gray-800);
    }
    
    .header {
        background-color: rgba(30, 41, 59, 0.95);
        border-bottom-color: var(--gray-200);
    }
    
    .cv-preview {
        background: var(--white);
        color: #333;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --primary-dark: #000080;
        --error-color: #ff0000;
        --success-color: #008000;
        --warning-color: #ff8c00;
    }
    
    .btn {
        border-width: 2px;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        border-width: 3px;
        box-shadow: none;
    }
    
    .nav-link.active::after {
        height: 4px;
    }
}

/* Loading States for Slow Connections */
@media (max-width: 767px) {
    .hero-visual,
    .demo-container {
        min-height: 200px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .template-preview {
        min-height: 300px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Accessibility Improvements */
@media (max-width: 767px) {
    /* Larger focus indicators on mobile */
    .btn:focus,
    .nav-link:focus,
    .tab-btn:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Better spacing for screen readers */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* Custom Scrollbars */
@media (min-width: 768px) {
    .form-panel,
    .preview-container {
        scrollbar-width: thin;
        scrollbar-color: var(--gray-400) var(--gray-100);
    }
    
    .form-panel::-webkit-scrollbar,
    .preview-container::-webkit-scrollbar {
        width: 8px;
    }
    
    .form-panel::-webkit-scrollbar-track,
    .preview-container::-webkit-scrollbar-track {
        background: var(--gray-100);
    }
    
    .form-panel::-webkit-scrollbar-thumb,
    .preview-container::-webkit-scrollbar-thumb {
        background: var(--gray-400);
        border-radius: 4px;
    }
    
    .form-panel::-webkit-scrollbar-thumb:hover,
    .preview-container::-webkit-scrollbar-thumb:hover {
        background: var(--gray-500);
    }
}
