/* ============================================
   Responsive Styles
   ============================================ */

/* ===== Large Screens (1200px and below) ===== */
@media (max-width: 1200px) {
    :root {
        --container-padding: var(--space-8);
    }

    .hero-container {
        gap: var(--space-12);
    }

    .hero-image-wrapper {
        width: 350px;
        height: 350px;
    }
}

/* ===== Medium Screens (992px and below) ===== */
@media (max-width: 992px) {
    .hero-container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-10);
    }

    .hero-content {
        order: 2;
    }

    .hero-visual {
        order: 1;
    }

    .hero-description {
        margin: 0 auto var(--space-8);
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-stats {
        justify-content: center;
    }

    .hero-float {
        display: none;
    }

    .about-container {
        grid-template-columns: 1fr;
        gap: var(--space-10);
    }

    .contact-container {
        grid-template-columns: 1fr;
        gap: var(--space-10);
    }

    .education-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Tablet (768px and below) ===== */
@media (max-width: 768px) {
    :root {
        --container-padding: var(--space-5);
    }

    section {
        padding: var(--space-16) 0;
    }

    /* Navigation */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: var(--bg-secondary);
        border-left: 1px solid var(--surface-border);
        flex-direction: column;
        justify-content: center;
        padding: var(--space-10);
        transition: right var(--transition-slow);
        z-index: var(--z-modal);
    }

    .nav-menu.active {
        right: 0;
    }

    .nav-links {
        flex-direction: column;
        gap: var(--space-8);
        margin-bottom: var(--space-8);
    }

    .nav-link {
        font-size: var(--text-lg);
    }

    .nav-actions {
        flex-direction: row;
    }

    .nav-toggle {
        display: flex;
        z-index: var(--z-tooltip);
    }

    /* Mobile menu overlay */
    .nav-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-slow);
        z-index: var(--z-modal-backdrop);
    }

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

    /* Hero */
    .hero {
        min-height: auto;
        padding: 120px 0 var(--space-16);
    }

    .hero-image-wrapper {
        width: 280px;
        height: 280px;
    }

    .hero-stats {
        flex-wrap: wrap;
        gap: var(--space-6);
    }

    /* Projects */
    .projects-grid {
        grid-template-columns: 1fr;
    }

    /* Experience */
    .experience-timeline::before {
        left: 15px;
    }

    .timeline-item {
        padding-left: 50px;
    }

    .timeline-dot {
        left: 5px;
        width: 20px;
        height: 20px;
    }

    .timeline-header {
        flex-direction: column;
        text-align: left;
    }

    .timeline-meta {
        text-align: left;
    }

    /* Awards */
    .awards-grid {
        grid-template-columns: 1fr;
    }

    /* Volunteering */
    .volunteering-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Scroll top */
    .scroll-top {
        right: var(--space-4);
        bottom: var(--space-4);
        width: 44px;
        height: 44px;
    }
}

/* ===== Mobile (576px and below) ===== */
@media (max-width: 576px) {
    :root {
        --container-padding: var(--space-4);
    }

    section {
        padding: var(--space-12) 0;
    }

    .section-header {
        margin-bottom: var(--space-10);
    }

    /* Hero */
    .hero-badge {
        font-size: var(--text-xs);
    }

    .hero-image-wrapper {
        width: 220px;
        height: 220px;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
    }

    .hero-stats {
        flex-direction: column;
        gap: var(--space-4);
    }

    .stat-item {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        text-align: left;
    }

    /* About */
    .about-info {
        grid-template-columns: 1fr;
    }

    .skills-section {
        padding: var(--space-5);
    }

    .skills-tabs {
        justify-content: center;
    }

    /* Education */
    .education-card {
        flex-direction: column;
        text-align: center;
    }

    /* Contact */
    .contact-form {
        padding: var(--space-5);
    }

    /* Cards general */
    .card {
        padding: var(--space-5);
    }

    .timeline-content {
        padding: var(--space-5);
    }

    .project-content {
        padding: var(--space-5);
    }
}

/* ===== Extra Small (400px and below) ===== */
@media (max-width: 400px) {
    .hero-image-wrapper {
        width: 180px;
        height: 180px;
    }

    .nav-menu {
        width: 100%;
        max-width: none;
    }

    .skill-tab {
        padding: var(--space-1) var(--space-3);
        font-size: var(--text-xs);
    }

    .badge {
        font-size: 0.65rem;
        padding: var(--space-1) var(--space-2);
    }
}

/* ===== RTL Support ===== */
[dir="rtl"] {
    .nav-menu {
        right: auto;
        left: -100%;
        border-left: none;
        border-right: 1px solid var(--surface-border);
    }

    [dir="rtl"] .nav-menu.active {
        left: 0;
    }

    .experience-timeline::before {
        left: auto;
        right: 20px;
    }

    .timeline-item {
        padding-left: 0;
        padding-right: 60px;
    }

    .timeline-dot {
        left: auto;
        right: 10px;
    }

    .timeline-content:hover {
        transform: translateX(-5px);
    }

    .timeline-description li {
        padding-left: 0;
        padding-right: var(--space-5);
    }

    .timeline-description li::before {
        left: auto;
        right: 0;
    }

    .timeline-meta {
        text-align: left;
    }

    .scroll-top {
        right: auto;
        left: var(--space-8);
    }
}

@media (max-width: 768px) {
    [dir="rtl"] .experience-timeline::before {
        right: 15px;
    }

    [dir="rtl"] .timeline-item {
        padding-right: 50px;
    }

    [dir="rtl"] .timeline-dot {
        right: 5px;
    }

    [dir="rtl"] .scroll-top {
        left: var(--space-4);
    }
}

/* ===== Print Styles ===== */
@media print {

    .navbar,
    .scroll-top,
    .nav-toggle,
    .theme-toggle,
    .lang-toggle {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    section {
        padding: var(--space-8) 0;
        page-break-inside: avoid;
    }

    .hero {
        min-height: auto;
        padding: var(--space-8) 0;
    }

    a {
        color: inherit;
        text-decoration: underline;
    }
}

/* ===== Landscape Mode on Mobile ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 100px 0 var(--space-10);
    }

    .hero-container {
        grid-template-columns: 1fr 1fr;
        text-align: left;
    }

    .hero-content {
        order: 1;
    }

    .hero-visual {
        order: 2;
    }

    .hero-image-wrapper {
        width: 200px;
        height: 200px;
    }

    .hero-buttons {
        justify-content: flex-start;
    }

    .hero-stats {
        justify-content: flex-start;
    }
}

/* ===== Mobile UX Enhancements ===== */
@media (max-width: 768px) {
    /* Improved touch targets */
    .nav-link,
    .social-link,
    .skill-tab,
    .contact-item a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better readability on mobile */
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .section-title {
        font-size: 1.875rem;
    }
    
    .hero-description {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    /* Improved project cards for mobile */
    .projects-grid {
        gap: 1.5rem;
    }
    
    .project-card {
        border-radius: var(--radius-lg);
        overflow: visible;
    }
    
    .project-image {
        margin-bottom: 1rem;
        border-radius: var(--radius-lg);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    /* Better form elements on mobile */
    input,
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.875rem 1rem;
    }
    
    /* Improved button spacing */
    .hero-buttons,
    .project-actions {
        gap: 0.75rem;
        width: 100%;
    }
    
    .hero-buttons .btn {
        flex: 1;
        min-width: 0;
    }
    
    /* Better stats display */
    .hero-stats {
        gap: 1rem;
        flex-wrap: wrap;
    }
    
    .stat-item {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    /* Improved timeline on mobile */
    .timeline-item {
        padding-left: 2rem;
    }
    
    .timeline-item::before {
        left: 0.5rem;
    }
    
    /* Better contact form spacing */
    .contact-form .form-group {
        margin-bottom: 1.25rem;
    }
    
    /* Scroll padding for anchor links */
    html {
        scroll-padding-top: 80px;
    }
    
    /* Prevent text selection on buttons */
    .btn,
    .nav-toggle,
    .theme-toggle,
    .lang-toggle {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        user-select: none;
    }
}

/* ===== Extra Small Mobile (380px and below) ===== */
@media (max-width: 380px) {
    .hero-title {
        font-size: 1.75rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .btn-lg {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-sm);
    }
    
    .stat-item {
        flex: 1 1 100%;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    .project-actions {
        flex-direction: column;
    }
    
    .project-actions .btn {
        width: 100%;
    }
}

/* ===== Hover Effects Optimization for Touch Devices ===== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover::before,
    .card:hover,
    .project-card:hover {
        animation: none;
        transform: none;
    }
    
    /* Show overlays by default on touch */
    .project-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(15, 23, 42, 0.9) 0%, transparent 60%);
    }
    
    /* Better active states for touch */
    .btn:active {
        transform: scale(0.97);
    }
    
    .card:active,
    .project-card:active {
        transform: translateY(2px);
    }
}
