/* Google Fonts - Inter for clean typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: #f5f5f7; 
    color: #1d1d1f;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Lock body, scroll inside container on mobile */
}

/* =========================================
   MOBILE FIRST STYLES (Default for Phones)
========================================= */

/* Header */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    align-items: center;
    z-index: 10;
}

.logo {
    font-size: 20px;
    font-weight: 600;
}

.logo span {
    color: #0066cc;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap; /* Wraps buttons nicely on small screens */
    justify-content: center;
    width: 100%;
}

/* Buttons */
.primary-btn, .secondary-btn {
    padding: 10px 16px;
    border-radius: 12px; /* Slightly squarer for mobile tap targets */
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1 1 calc(50% - 8px); /* Take up half width minus gap on phones */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.primary-btn {
    background-color: #0066cc;
    color: white;
    border: none;
}

.primary-btn:hover { background-color: #005bb5; }

.secondary-btn {
    background-color: #f5f5f7;
    color: #1d1d1f;
    border: 1px solid #d2d2d7;
}

.secondary-btn:hover {
    background-color: #e5e5ea;
    border-color: #c7c7cc;
}

/* Main Layout */
.app-container {
    display: flex;
    flex-direction: column; /* Vertical stack on mobile */
    flex: 1;
    gap: 16px;
    padding: 16px;
    overflow-y: auto; /* Scrollable on mobile */
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}

.editor-section, .preview-section {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    overflow: hidden;
    min-height: 450px; /* Give explicit height on mobile */
    flex-shrink: 0;
}

.section-header {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e5ea;
    background: #fafafa;
}

.section-header h3 {
    font-size: 13px;
    color: #86868b;
    font-weight: 500;
}

#code-input {
    flex: 1;
    width: 100%;
    padding: 16px;
    border: none;
    resize: none;
    font-family: monospace;
    font-size: 13px;
    background-color: #1e1e1e;
    color: #d4d4d4;
    outline: none;
}

.canvas-wrapper {
    flex: 1;
    padding: 20px; /* Compact padding for mobile */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e5e5ea; 
    overflow: auto;
}

#render-area {
    background-color: transparent;
    transition: all 0.3s ease;
}

/* Modal Styles - Mobile Bottom Sheet */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: flex-end; /* Align bottom on mobile */
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #ffffff; width: 100%; border-radius: 20px 20px 0 0; /* Only top corners rounded */
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15); overflow: hidden;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    max-height: 85vh; display: flex; flex-direction: column;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-header {
    padding: 16px 20px; border-bottom: 1px solid #e5e5ea;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: #1d1d1f; }
.close-modal { cursor: pointer; color: #86868b; border: none; background: none; font-size: 20px; transition: color 0.2s; }

.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; background: #fafafa; }

.new-folder-btn {
    width: 100%; padding: 14px; background: #ffffff; border: 1px dashed #d2d2d7;
    border-radius: 12px; cursor: pointer; font-weight: 500; color: #0066cc;
    transition: all 0.2s ease; font-size: 14px; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.new-folder-btn:hover { background: #f0f8ff; border-color: #0066cc; }

.folder-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.folder-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; background: #ffffff; border: 1px solid #e5e5ea;
    border-radius: 12px;
}

.folder-name { font-weight: 500; font-size: 13px; color: #1d1d1f; display: flex; align-items: center; gap: 8px; }
.folder-name i { color: #0066cc; font-size: 16px; }

.save-here-btn {
    background: #0066cc; color: white; border: none; padding: 8px 12px;
    border-radius: 8px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.save-here-btn:disabled { background: #a0c4ff; cursor: not-allowed; }

/* =========================================
   DESKTOP & TABLET STYLES (Responsive Override)
========================================= */
@media (min-width: 768px) {
    
    /* Header layout restores to Row */
    .app-header {
        flex-direction: row;
        padding: 16px 32px;
    }

    .header-actions {
        width: auto;
        flex-wrap: nowrap;
    }

    .primary-btn, .secondary-btn {
        flex: 0 0 auto;
        border-radius: 20px; /* Fully rounded pills for desktop */
        padding: 10px 20px;
        font-size: 14px;
    }

    /* Main Container layout restores to 50/50 Split */
    .app-container {
        flex-direction: row;
        padding: 24px 32px;
        overflow: hidden; /* Lock container scroll */
    }

    .editor-section, .preview-section {
        flex: 1; 
        min-height: 0; 
        height: 100%; /* Fill container */
    }

    .section-header { padding: 16px 20px; }
    .section-header h3 { font-size: 14px; }
    #code-input { padding: 20px; font-size: 14px; }
    .canvas-wrapper { padding: 40px; }

    /* Modal restores to Center Card */
    .modal-overlay { align-items: center; } /* Center vertically */
    .modal-content {
        width: 420px;
        border-radius: 20px; /* Fully rounded corners again */
        transform: scale(0.95); /* Pop-up scale effect */
    }
    .modal-overlay.active .modal-content { transform: scale(1); }
    .modal-header { padding: 20px 24px; }
    .modal-header h3 { font-size: 16px; }
    .modal-body { padding: 20px 24px; }
    .folder-item { padding: 12px 16px; }
    .folder-name { font-size: 14px; }
    .save-here-btn { padding: 8px 16px; }
}
