/* Modern Dark Purple & Teal Theme for CodeCraft AI Compiler */
:root {
    --bg-color: #141228;
    --bg-accent: #1d1a3a;
    --primary: #5ccea3;
    --secondary: #5b54c9;
    --accent: #e864e8;
    --text-color: #e1e1e1;
    --text-secondary: #9ca3af;
    --dark-accent: #0d0b1d;
    --card-bg: #1d1a3a;
    --border-color: #2a2657;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    --glow: 0 0 15px rgba(92, 206, 163, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    margin: 0;
    position: relative;
    overflow-y: auto; /* Enable vertical scrolling */
}

/* Noise overlay for texture */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAB50lEQVR4nO3aPY9PURSF4fcwPwEjRqOTKBRmFAqVQqMxoaAgPgrxUWhUCpGIQqEgIj4KnUI0KtEoNOgUGolCoYCZKAzNLnQ34s65Z9/zvi33STbFPmvtfe7N2TlrrwEhhBBCCCGEEEIYsBFgAdgFjoAfwBrwENgCDv+ow1/GMnqtAR+BY+ApsAJcz3lBF4BnwA/gG/AU6PSZ8wW4ltjHDLCZmPcJmE+2pEt54N+AGwnZHeBJQu4bUo/BTmq9eryTdlETeRtImSngnbHGx5RFWo/BYsqLTchZT8jMpK452SPGDeA7MJ2Q9cyY/z6waMzOpVzQT+CSMbtjzD4Crhqzc9VtPAGcM2Y7xuxH4JIxO+cF7Bqzp43ZdeN31JxVYMWYX036b1JuqdTcYm3uSuoipS5o21vj7zkPXSvxAshZbrc298Zcdc4ZK3Eh03nXgMvGbOvXP6zvmStJb8ByGZumLvB70ncTcw1vwDaDtmmcYYeAJeAVsEyh74F54CPwGrhTou2KUW1a2wXarRzFhfxP1esi1e3dGPB7M/pUosh3YJvek1XrDKzu2Mq+ZNvMfWPTKplr5pHUx2eab8BsQh9Twq8YHUfpo1ppU5vm3CTd0ZT824ScN59TG2l9DHeAGz3GbwmHxs/A7T9mQgghhBBCCCGEMP5+AQs2qBEU2pJfAAAAAElFTkSuQmCC');
    opacity: 0.025;
    pointer-events: none;
    z-index: -1;
}

/* Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2.5rem;
}

.main-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 130px);
    overflow-y: auto; /* Enable vertical scrolling */
    position: relative; /* Ensure proper stacking context */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.highlight {
    color: var(--primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Navbar */
.navbar {
    background-color: rgba(25, 22, 55, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    transition: color 0.3s, transform 0.3s;
    position: relative;
    padding: 0.5rem 0;
}

.nav-links a:hover {
    color: var(--primary);
    transform: translateY(-2px);
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

.nav-links a:hover::after {
    width: 100%;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    flex: 1;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.select-wrapper span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.styled-select {
    background-color: var(--dark-accent);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    min-width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2300e5b0%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.8rem auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.styled-select:hover {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(0, 229, 176, 0.3);
}

.styled-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 229, 176, 0.25);
}

.icon-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    background-color: var(--dark-accent);
    border: 1px solid var(--border-color);
}

.icon-button:hover {
    color: var(--primary);
    background-color: rgba(0, 229, 176, 0.1);
}

/* Main App Content */
.app-main {
    display: flex;
    flex: 1;
    gap: 3rem;
    padding: 2.5rem 0;
    overflow-y: visible; /* Allow content to scroll */
    min-height: min-content; /* Ensure proper height calculation */
}

@media (max-width: 992px) {
    .app-main {
        flex-direction: column; /* Stack on smaller screens */
    }
}

/* Input Section, Output Section */
.input-section, .output-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.language-selector,
.output-actions {
    display: flex;
    gap: 0.5rem;
}

/* Code Container */
.code-container {
    flex: 1;
    background-color: var(--bg-accent);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    min-height: 300px;
}

/* Input Container */
.input-container {
    width: 100%;
    display: block;
    margin-bottom: 1rem;
}

.resizer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 5px;
    background: var(--border-color);
    cursor: ns-resize;
    z-index: 10;
}

.resizer:hover {
    background: var(--primary);
}

/* Input Area improved styling */
.input-area {
    height: 120px;
    background-color: var(--bg-accent);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.2rem;
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color 0.3s, box-shadow 0.3s;
    line-height: 1.6;
    width: 100%;
    min-height: 80px;
    max-height: 300px;
}

.input-area:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 229, 176, 0.25);
}

.input-area::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Output Container */
.output-container {
    flex: 1;
    background-color: var(--dark-accent);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.2rem;
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

#output {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-accent {
    padding: 0.9rem 1.6rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

#run-button {
    font-size: 1.05rem;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.action-buttons button {
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-save {
    background: linear-gradient(135deg, var(--primary), #4ab890);
    color: var(--dark-accent);
    border: none;
    box-shadow: 0 4px 15px rgba(92, 206, 163, 0.25);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(92, 206, 163, 0.35);
}

.btn-share {
    background: linear-gradient(135deg, rgba(91, 84, 201, 0.15), rgba(108, 98, 255, 0.15));
    color: var(--secondary);
    border: 1px solid var(--secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.btn-share:hover {
    background: linear-gradient(135deg, rgba(91, 84, 201, 0.25), rgba(108, 98, 255, 0.25));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(91, 84, 201, 0.25);
}

/* Share modal styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
}

.modal-content {
    background: rgba(35, 31, 69, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    max-width: 550px;
    margin: 10% auto;
    padding: 35px;
    position: relative;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    transform: translateY(50px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.show .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
    background: linear-gradient(to right, #ffffff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(16, 14, 41, 0.5);
}

.modal-close:hover {
    color: var(--primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.share-url-container {
    display: flex;
    gap: 12px;
    margin: 25px 0;
}

.share-url-input {
    flex-grow: 1;
    padding: 15px 20px;
    border-radius: 12px;
    background-color: rgba(16, 14, 41, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.share-url-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 229, 176, 0.15);
}

.copy-button {
    padding: 12px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #05c299);
    color: var(--dark-accent);
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 229, 176, 0.25);
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-button:hover {
    background: linear-gradient(135deg, #05c299, var(--primary));
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 229, 176, 0.35);
}

.share-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.share-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.share-option:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
}

.option-twitter {
    background: linear-gradient(135deg, #1DA1F2, #1a94e4);
    color: white;
}

.option-facebook {
    background: linear-gradient(135deg, #4267B2, #3b5998);
    color: white;
}

.option-linkedin {
    background: linear-gradient(135deg, #0077B5, #006399);
    color: white;
}

.option-email {
    background: linear-gradient(135deg, #D44638, #c23321);
    color: white;
}

@media (max-width: 992px) {
    .container {
        padding: 0 2rem;
    }
    
    .app-header {
        padding: 2rem 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
    
    .language-selector {
        width: 100%;
        justify-content: space-between;
    }
    
    .main-container {
        min-height: auto;
        height: auto;
    }
    
    .app-main {
        flex-direction: column;
        gap: 2rem;
        height: auto;
        padding-bottom: 2rem;
    }
    
    .code-container {
        min-height: 400px;
    }
    
    /* Adjust button sizes for better touch targets */
    .action-buttons button {
        padding: 0.9rem 1.2rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .app-header {
        padding: 1.8rem 0;
    }
    
    .header-content h1 {
        font-size: 2.2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .styled-select {
        min-width: 160px;
        font-size: 0.9rem;
        padding: 0.7rem 1rem;
    }
    
    .select-wrapper span {
        font-size: 0.8rem;
    }
    
    /* Navbar mobile adjustments */
    .navbar {
        padding: 0.8rem 0;
    }
    
    .nav-container {
        position: relative;
    }
    
    .nav-links {
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        background-color: var(--bg-accent);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 1rem;
        box-shadow: var(--shadow);
        width: 200px;
        gap: 1rem;
        display: none;
        z-index: 100;
    }
    
    .nav-links.show {
        display: flex;
    }
    
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .output-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        gap: 0.8rem;
        justify-content: space-between;
    }
    
    .action-buttons button {
        flex: 1;
        min-width: 120px;
        text-align: center;
        display: flex;
        justify-content: center;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Code container adjustments */
    .code-container {
        min-height: 300px;
    }
    
    /* CodeMirror adjustments */
    .CodeMirror {
        font-size: 0.95rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 1.2rem;
    }
    
    .app-header {
        padding: 1.5rem 0;
    }
    
    .header-content h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .app-main {
        gap: 1.5rem;
        padding: 1rem 0;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .footer-links {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1.2rem;
    }
    
    /* Button styling for mobile */
    #run-button {
        width: 100%;
        padding: 0.9rem 1rem;
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .btn-primary, .btn-secondary, .btn-accent {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Input and output adjustments */
    .input-area {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .output-container {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* Smaller code section on mobile */
    .code-container {
        min-height: 250px;
    }
    
    /* CodeMirror adjustments */
    .CodeMirror {
        font-size: 0.9rem;
        padding: 0.5rem 0.3rem;
    }
    
    .CodeMirror-gutters {
        padding-right: 5px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 375px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content h1 {
        font-size: 1.6rem;
    }
    
    .language-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .select-wrapper {
        width: 100%;
    }
    
    .styled-select {
        width: 100%;
    }
    
    .section-header h2 {
        font-size: 1.3rem;
    }
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 100;
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
}