:root {
    --bg-body: #000000;
    --bg-panel: #111111;
    --bg-input: #1a1a1a;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #06b6d4;
    --border: #333333;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    padding-bottom: 50px;
}

/* Navbar */
.navbar {
    background: rgba(17, 17, 17, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon-bg {
    background: linear-gradient(135deg, var(--bg-panel), var(--primary-hover));
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.head { font-weight: 700; font-size: 1.1rem; }
.tagline { font-size: 0.8rem; color: var(--text-muted); }

/* Main Layout */
.main-wrapper {
    max-width: 1500px;
    width: 95%;
    margin: 100px auto 40px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Container Styles */
.qr-container, .style-section, .saved-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Top Section (Generator) */
.top-section {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}

.left-panel, .right-panel {
    flex: 1;
    width: 100%;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.tab-container {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-body);
    padding: 5px;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab.active {
    background: var(--bg-panel);
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

textarea, input[type="url"], input[type="text"] {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    outline: none;
    transition: 0.2s;
}

textarea:focus, input:focus {
    border-color: var(--primary);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.process-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: var(--primary-hover);
    color: white;
    font-weight: 600;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: opacity 0.2s;
}

.process-btn:hover { opacity: 0.9; }

/* Right Panel (Preview) */
.right-panel {
    background: var(--bg-body);
    border-radius: 20px;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    position: relative;
    overflow: hidden;
}

.placeholder {
    text-align: center;
    color: var(--text-muted);
}
.placeholder i { width: 48px; height: 48px; margin-bottom: 10px; opacity: 0.5; }

/* QR Canvas Responsive Fix */
#qrcode canvas, #qrcode svg {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

/* Style Section */
.style-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 2rem;
    
    /* Hidden State */
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-20px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Visuals */
    margin-top: -20px;
    border-top: none;
}

.style-section.visible {
    max-height: 5000px;
    opacity: 1;
    transform: translateY(0);
    padding: 2rem;
    margin-top: 0;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.style-card {
    background: var(--bg-body);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.style-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-group { margin-bottom: 1.5rem; }

.control-group label {
    display: block;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.color-picker-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-picker-wrapper input[type="color"] {
    width:60px;
    height: 55px;
    border: none;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    background: none;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: #333;
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #00bfff;
    border-radius: 50%;
    cursor: pointer;
}

.pattern-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.pattern-btn {
    background: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.pattern-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.file-input {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    gap: 10px;
}

.action-btn {
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download { background: var(--text-main); color: var(--bg-body); }
.save { background: #10b981; color: white; }
.save:hover { background: #059669; }

/* Saved Section */
.saved-section { margin-bottom: 2rem; }
.saved-header {
    text-align: center;
    padding: 2rem;
}
.saved-header.hidden { display: none; }

.saved-icon {
    width: 60px;
    height: 60px;
    background: var(--bg-body);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--text-muted);
}

.saved-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Saved Card */
.saved-card {
    background: var(--bg-body);
    padding: 1rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.saved-card:hover { transform: translateY(-5px); border-color: var(--primary); }

.saved-card img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
}

.saved-text {
    color: var(--text-main);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-bottom: 8px;
    text-align: left;
}

.saved-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; 
    border-top: 1px solid #222;
    padding-top: 8px;
}

.saved-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.delete-btn {
    background: transparent;
    border: none;
    color: #888; 
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.delete-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}
.delete-btn i { width: 18px; height: 18px; }


/* === MODAL STYLES === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none; 
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.open { display: flex; opacity: 1; }

.modal-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 340px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-overlay.open .modal-box { transform: scale(1); }

.modal-icon {
    width: 50px;
    height: 50px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.2rem;
}
.modal-icon i { width: 24px; height: 24px; }

.modal-title { 
    font-size: 1.2rem; 
    font-weight: 600; 
    margin-bottom: 1.5rem; 
    color: #fff; 
    line-height: 1.4;
}

.highlight-text { 
    color: var(--danger); 
    font-weight: 700;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-cancel { background: #222; color: #fff; border: 1px solid #333; }
.btn-cancel:hover { background: #333; }

.btn-confirm { background: var(--danger); color: #fff; }
.btn-confirm:hover { background: #dc2626; }

/* =========================================================
RESPONSIVE FIXES (FULL + CLEAN + READY)
========================================================= */

@media (max-width: 1024px) {
    .top-section {
        flex-direction: column;
        gap: 2rem;
    }

    .style-grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    }
}


@media (max-width: 768px) {

    .main-wrapper {
        width: 92%;
    }

    .tab {
        font-size: 0.9rem;
    }

    .style-card {
        padding: 1.3rem;
    }

    .style-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .pattern-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ============================
420px — Compact Mobile
============================ */
@media (max-width: 420px) {

    .style-section.visible {
        padding: 1.2rem;
    }

    .section-title {
        font-size: 1.05rem;
        gap: 6px;
    }

    .style-grid {
        grid-template-columns: 1fr;
        gap: 1.3rem;
    }

    .style-card {
        padding: 1.1rem;
        border-radius: 14px;
    }

    .control-group label {
        font-size: 0.85rem;
    }

    textarea,
    input[type="url"],
    input[type="text"] {
        font-size: 0.85rem;
        padding: 0.85rem;
    }

    input[type="color"] {
        width: 40px !important;
        height: 40px !important;
    }

    .pattern-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* File input long text fix */
    .file-input {
        font-size: 0.8rem;
        white-space: normal;
        word-break: break-word;
    }
}


/* ============================
360px — Small Mobile
============================ */
@media (max-width: 360px) {

    .style-section.visible {
        padding: 1rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .style-card {
        padding: 0.95rem;
    }

    .control-group label {
        font-size: 0.78rem;
        margin-bottom: 0.5rem;
    }

    textarea,
    input[type="url"],
    input[type="text"] {
        padding: 0.75rem;
        font-size: 0.8rem;
    }

    input[type="color"] {
        width: 36px !important;
        height: 36px !important;
    }

    .pattern-grid {
        grid-template-columns: 1fr;
    }

    .pattern-btn {
        padding: 8px;
        font-size: 0.78rem;
    }

    .file-input {
        font-size: 0.75rem;
    }
}


/* ============================
320px — Ultra Small Screens
FIXES YOUR EXACT PROBLEM
============================ */
@media (max-width: 320px) {

    .style-section.visible {
        padding: 0.8rem;
    }

    .section-title {
        font-size: 0.9rem;
        gap: 5px;
    }

    .style-card {
        padding: 0.85rem;
        border-radius: 12px;
    }

    .control-group {
        margin-bottom: 1rem;
    }

    .control-group label {
        font-size: 0.72rem;
    }

    textarea,
    input[type="url"],
    input[type="text"] {
        padding: 0.7rem;
        font-size: 0.78rem;
    }

    input[type="color"] {
        width: 32px !important;
        height: 32px !important;
    }

    .pattern-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .pattern-btn {
        padding: 7px;
        font-size: 0.7rem;
    }

    .file-input {
        font-size: 0.7rem;
        line-height: 1.2;
        white-space: normal;
        word-break: break-word;
    }

    .saved-list {
        grid-template-columns: 1fr;
    }

    .saved-card {
        padding: 0.7rem;
    }
}
