/* ===== CSS RESET & BASE STYLES ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== CSS VARIABLES ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: #ffffff;
    --bg-secondary: #f8fafc;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.3s ease;
    
    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
}

/* Dark theme variables */
[data-theme="dark"] {
    --text-color: #f9fafb;
    --text-light: #d1d5db;
    --bg-color: #111827;
    --bg-secondary: #1f2937;
    --border-color: #374151;
}

/* ===== UTILITY CLASSES ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.section-title {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-12);
    color: var(--text-color);
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

/* ===== HEADER & NAVIGATION ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: var(--transition);
}

[data-theme="dark"] .header {
    background: rgba(17, 24, 39, 0.95);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-logo {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.nav-logo:hover {
    transform: scale(1.05);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--space-8);
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

.bar {
    width: 25px;
    height: 3px;
    background: var(--text-color);
    margin: 3px 0;
    transition: var(--transition);
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: var(--transition);
    margin-left: var(--space-4);
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ===== HERO SECTION ===== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: var(--space-20) 0;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
}

.hero-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
    align-items: center;
}

.hero-title {
    font-size: var(--font-size-5xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-4);
    color: var(--text-color);
}

.hero-name {
    color: var(--primary-color);
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    color: var(--text-light);
    margin-bottom: var(--space-6);
    font-weight: 500;
}

.hero-description {
    font-size: var(--font-size-lg);
    color: var(--text-light);
    margin-bottom: var(--space-8);
    line-height: 1.7;
}

.hero-buttons {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.hero-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-img {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    object-fit: cover;
    border: 5px solid var(--primary-color);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    background: var(--bg-secondary);
}

.profile-img:hover {
    transform: scale(1.05);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
    font-size: var(--font-size-base);
    transition: var(--transition);
    border: 2px solid transparent;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-full {
    width: 100%;
}

/* ===== ABOUT SECTION ===== */
.about {
    padding: var(--space-20) 0;
    background: var(--bg-color);
}

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-16);
    align-items: center;
}

.about-description {
    font-size: var(--font-size-lg);
    color: var(--text-light);
    margin-bottom: var(--space-6);
    line-height: 1.7;
}

.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
    margin-top: var(--space-8);
}

.stat {
    text-align: center;
    padding: var(--space-6);
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.stat:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.stat-number {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--space-2);
}

.stat-label {
    color: var(--text-light);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.about-img {
    width: 100%;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.about-img:hover {
    transform: scale(1.02);
}

/* ===== SKILLS SECTION ===== */
.skills {
    padding: var(--space-20) 0;
    background: var(--bg-secondary);
}

.skills-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-12);
}

.skills-category {
    background: var(--bg-color);
    padding: var(--space-8);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.skills-category:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.skills-category-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: var(--space-6);
    text-align: center;
}

.skill-item {
    margin-bottom: var(--space-6);
}

.skill-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.skill-name {
    font-weight: 500;
    color: var(--text-color);
}

.skill-percentage {
    color: var(--primary-color);
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.skill-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.skill-progress {
    height: 100%;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 4px;
    width: 0%;
    transition: width 1.5s ease-in-out;
}

/* ===== PROJECTS SECTION ===== */
.projects {
    padding: var(--space-20) 0;
    background: var(--bg-color);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-8);
}

.project-card {
    background: var(--bg-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-lg);
}

.project-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(37, 99, 235, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.project-card:hover .project-overlay {
    opacity: 1;
}

.project-links {
    display: flex;
    gap: var(--space-4);
}

.project-link {
    background: white;
    color: var(--primary-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: var(--font-size-lg);
    transition: var(--transition);
}

.project-link:hover {
    transform: scale(1.1);
    background: var(--accent-color);
    color: white;
}

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

.project-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: var(--space-3);
}

.project-description {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.project-tag {
    background: var(--bg-secondary);
    color: var(--primary-color);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--border-radius);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border: 1px solid var(--border-color);
}

/* ===== CONTACT SECTION ===== */
.contact {
    padding: var(--space-20) 0;
    background: var(--bg-secondary);
}

.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
}

.contact-title {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: var(--space-4);
}

.contact-description {
    color: var(--text-light);
    font-size: var(--font-size-lg);
    line-height: 1.7;
    margin-bottom: var(--space-8);
}

.contact-details {
    margin-bottom: var(--space-8);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.contact-item i {
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
}

.contact-text h4 {
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.contact-text p {
    color: var(--text-light);
}

.social-links {
    display: flex;
    gap: var(--space-4);
}

.social-link {
    width: 50px;
    height: 50px;
    background: var(--bg-color);
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: var(--font-size-lg);
    transition: var(--transition);
}

.social-link:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

/* ===== CONTACT FORM ===== */
.contact-form {
    background: var(--bg-color);
    padding: var(--space-8);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

/* Form row for responsive layout */
.form-row {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: 1fr;
}

.form-group {
    margin-bottom: var(--space-6);
    position: relative;
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--text-color);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.required {
    color: #ef4444;
    font-weight: 600;
}

.form-input {
    width: 100%;
    padding: var(--space-4);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: var(--font-size-base);
    transition: var(--transition);
    font-family: inherit;
    min-height: 44px; /* Touch-friendly minimum height */
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input:hover {
    border-color: var(--secondary-color);
}

.form-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

/* Error states */
.form-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
    color: #ef4444;
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
    min-height: 1rem;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
}

.form-error.show {
    opacity: 1;
    transform: translateY(0);
}

/* Submit button enhancements */
.btn {
    position: relative;
    overflow: hidden;
}

.btn-loading {
    display: none;
}

.btn.loading .btn-text {
    opacity: 0;
}

.btn.loading .btn-loading {
    display: inline-block;
}

.form-status {
    margin-top: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.form-status.show {
    opacity: 1;
    transform: translateY(0);
}

.form-status.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.form-status.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .form-status.success {
    background: #052e16;
    color: #bbf7d0;
    border-color: #166534;
}

[data-theme="dark"] .form-status.error {
    background: #450a0a;
    color: #fecaca;
    border-color: #991b1b;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--text-color);
    color: white;
    padding: var(--space-8) 0;
    text-align: center;
}

.footer-content p {
    margin-bottom: var(--space-2);
    opacity: 0.8;
}

/* ===== BACK TO TOP ===== */
.back-to-top {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: var(--font-size-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Desktop styles (≥1024px) - 2 column layout for name/email */
@media (min-width: 1024px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-6);
    }
    
    .form-textarea {
        min-height: 140px;
    }
    
    .contact-form {
        padding: var(--space-10);
    }
    
    .form-input {
        padding: var(--space-5);
        font-size: var(--font-size-lg);
    }
    
    .btn-full {
        padding: var(--space-4) var(--space-8);
        font-size: var(--font-size-lg);
    }
}

/* Tablet styles (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-5);
    }
    
    .form-group {
        margin-bottom: var(--space-5);
    }
    
    .form-input {
        padding: var(--space-4);
        min-height: 48px;
    }
    
    .form-textarea {
        min-height: 130px;
    }
    
    .contact-form {
        padding: var(--space-8);
    }
}

/* Mobile styles (≤767px) */
@media (max-width: 767px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
    
    .form-group {
        margin-bottom: var(--space-4);
    }
    
    .form-input {
        padding: var(--space-4);
        min-height: 44px; /* Apple touch guidelines */
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .form-textarea {
        min-height: 120px;
        padding: var(--space-4);
    }
    
    .form-label {
        font-size: var(--font-size-base);
        margin-bottom: var(--space-2);
    }
    
    .contact-form {
        padding: var(--space-6);
    }
    
    .btn-full {
        min-height: 44px;
        font-size: var(--font-size-base);
        padding: var(--space-4);
    }
    
    /* Ensure adequate spacing between form elements */
    .form-group + .form-group {
        margin-top: var(--space-2);
    }
}

@media (max-width: 768px) {
    /* Navigation */
    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        background: var(--bg-color);
        width: 100%;
        text-align: center;
        transition: 0.3s;
        box-shadow: var(--shadow);
        border-top: 1px solid var(--border-color);
        padding: var(--space-4) 0;
    }

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

    .nav-toggle {
        display: flex;
    }

    .nav-toggle.active .bar:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .nav-toggle.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /* Hero Section */
    .hero-container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-8);
    }

    .hero-title {
        font-size: var(--font-size-3xl);
    }

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

    .profile-img {
        width: 250px;
        height: 250px;
    }

    /* About Section */
    .about-content {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

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

    /* Skills Section */
    .skills-content {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

    /* Projects Section */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }

    /* Contact Section */
    .contact-content {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }

    /* Typography adjustments */
    .section-title {
        font-size: var(--font-size-2xl);
    }

    .container {
        padding: 0 var(--space-4);
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: var(--font-size-2xl);
    }

    .hero-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

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

    .skills-content {
        grid-template-columns: 1fr;
    }

    .profile-img {
        width: 200px;
        height: 200px;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease-out;
}

/* ===== SCROLL REVEAL ===== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Focus states for better accessibility */
.nav-link:focus,
.btn:focus,
.form-input:focus,
.social-link:focus,
.project-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .header,
    .nav-toggle,
    .theme-toggle,
    .back-to-top,
    .contact-form {
        display: none;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    .section-title {
        color: black;
        page-break-after: avoid;
    }
    
    .project-card,
    .skill-item {
        page-break-inside: avoid;
    }
}