/* =========================================
   1. VARIABLES & RESET (SAME AS BEFORE)
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-primary: #ffffff; --bg-secondary: #f8fafc; --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a; --text-secondary: #475569; --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --accent-primary: #2563eb; --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --radius-md: 0.5rem; --radius-lg: 0.75rem;
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="dark"] {
    --bg-primary: #0f172a; --bg-secondary: #1e293b; --bg-tertiary: #334155;
    --text-primary: #f8fafc; --text-secondary: #cbd5e1; --text-tertiary: #94a3b8;
    --border-color: #334155; --accent-primary: #60a5fa;
    --glass-bg: rgba(15, 23, 42, 0.9);
}
body { font-family: 'Inter', sans-serif; background-color: var(--bg-primary); color: var(--text-primary); line-height: 1.6; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.btn { cursor: pointer; border: none; padding: 0.75rem 1.5rem; border-radius: var(--radius-md); font-weight: 500; transition: var(--transition-base); }
.btn-primary { background: var(--accent-gradient); color: white; }
.btn-secondary { background: var(--bg-primary); border: 1px solid var(--border-color); color: var(--text-primary); }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* =========================================
   2. HEADER & NAVIGATION (FIXED)
   ========================================= */
.main-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background-color: var(--glass-bg); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color); height: 70px;
    display: flex; align-items: center;
}
.header-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1rem; display: flex; justify-content: space-between; align-items: center; }
.logo-link { text-decoration: none; display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 35px; height: 35px; background: var(--accent-gradient); color: white; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: bold; font-family: 'Poppins', sans-serif; }
.site-title { font-size: 1.25rem; color: var(--text-primary); margin: 0; }
.header-controls { display: flex; gap: 10px; align-items: center; }
.theme-toggle { width: 40px; height: 24px; background: var(--bg-tertiary); border-radius: 20px; position: relative; border: 1px solid var(--border-color); cursor: pointer; }
.theme-toggle-inner { width: 16px; height: 16px; background: var(--text-secondary); border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: 0.3s; }
[data-theme="dark"] .theme-toggle-inner { transform: translateX(16px); background: var(--accent-primary); }
.main-nav { margin-left: auto; margin-right: 20px; }
.nav-list { display: flex; list-style: none; gap: 20px; }
.nav-link { text-decoration: none; color: var(--text-secondary); font-weight: 500; transition: 0.3s; }
.nav-link:hover, .nav-link.active { color: var(--accent-primary); }
.hamburger-menu { display: none; background: none; border: none; cursor: pointer; }
@media (max-width: 768px) {
    .main-nav { display: none; position: absolute; top: 70px; left: 0; right: 0; background: var(--bg-primary); padding: 20px; border-bottom: 1px solid var(--border-color); }
    .main-nav.active { display: block; }
    .nav-list { flex-direction: column; align-items: center; }
    .hamburger-menu { display: block; }
    .hamburger-line { display: block; width: 25px; height: 2px; background: var(--text-primary); margin: 5px 0; }
}

/* =========================================
   3. TOOL PAGES LAYOUT (CRITICAL FIX)
   ========================================= */
.tool-main { padding-top: 80px; padding-bottom: 4rem; }
.tool-hero { text-align: center; padding: 3rem 1rem; background: linear-gradient(to bottom, var(--bg-secondary), var(--bg-primary)); }
.tool-title { font-size: 2rem; margin-bottom: 0.5rem; }
.tool-subtitle { color: var(--text-secondary); }

/* The Grid Layout */
.tool-container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.tool-wrapper {
    display: grid;
    grid-template-columns: 1fr 400px; /* Controls Left, Preview Right */
    gap: 2rem;
    align-items: start;
}

/* Controls Section (Left) */
.tool-controls-section {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.control-group { margin-bottom: 1.5rem; }
.control-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-primary); }
.control-input, .control-select, .control-textarea {
    width: 100%; padding: 0.75rem;
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-secondary); color: var(--text-primary);
    font-size: 1rem; transition: 0.2s;
}
.control-input:focus, .control-textarea:focus { border-color: var(--accent-primary); outline: none; background: var(--bg-primary); }
.control-range { width: 100%; cursor: pointer; }
.color-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.color-picker { width: 100%; height: 40px; border: none; cursor: pointer; background: none; }
.generate-btn { width: 100%; font-size: 1.1rem; padding: 1rem; margin-top: 1rem; }

/* Preview Section (Right - Sticky) */
.tool-preview-section {
    position: sticky;
    top: 100px; /* Sticks when scrolling */
}

.preview-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.qr-preview, .barcode-preview {
    min-height: 250px;
    background: white; /* Always white background for code visibility */
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}

.qr-preview img, .barcode-preview canvas, .barcode-preview svg {
    max-width: 100%;
    height: auto;
}

.preview-controls { display: flex; flex-direction: column; gap: 0.5rem; }

/* Responsive Tool Layout */
@media (max-width: 900px) {
    .tool-wrapper { grid-template-columns: 1fr; } /* Stack on mobile */
    .tool-preview-section { position: static; order: -1; margin-bottom: 2rem; } /* Preview first on mobile */
}

/* =========================================
   4. SOCIAL QR PAGE DESIGN (FIXED)
   ========================================= */
.social-qr-section { padding: 2rem 0; }
.social-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.social-platform-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: var(--transition-base);
}
.social-platform-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: var(--accent-primary); }

.social-icon {
    width: 60px; height: 60px;
    margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--accent-primary);
}
.social-icon svg { width: 32px; height: 32px; }

/* Social Modal */
.social-generator-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-content {
    background: var(--bg-primary);
    width: 90%; max-width: 450px;
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    position: relative;
}
.modal-header { display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }

/* =========================================
   5. FOOTER (FIXED ICONS)
   ========================================= */
.main-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 1rem 1rem;
    margin-top: auto;
}
.footer-middle { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2rem; margin-bottom: 2rem; }
.footer-social { display: flex; gap: 10px; }
.footer-social a {
    width: 40px; height: 40px;
    background: white; border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: 0.3s;
}
.footer-social a:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.footer-bottom { text-align: center; border-top: 1px solid var(--border-color); padding-top: 1.5rem; }
.footer-links-bottom { display: flex; justify-content: center; gap: 15px; margin-bottom: 10px; flex-wrap: wrap; }
.footer-links-bottom a { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; }
.footer-copyright { color: var(--text-tertiary); font-size: 0.85rem; }