:root {
    /* Color Palette - Minimalist Premium */
    --primary: #6366f1; /* Keeping indigo for the glow */
    --primary-glow: rgba(99, 102, 241, 0.6);
    
    --bg-app: #ffffff;
    --bg-sidebar: #f5f5f7; /* Light Grey */
    --bg-rail: #f5f5f7; /* Light Grey match sidebar */
    
    --text-main: #000000; /* Black */
    --text-muted: #111111;
    --text-light: #444444;
    
    --border: #e2e8f0;
    --accent: #10b981;
    
    /* Layout Variables */
    --rail-width: 80px;
    --sidebar-width: 380px;
    
    /* Effects */
    --shadow-card: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-float: 0 10px 30px rgba(0,0,0,0.08);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-app: #020617;
    --bg-sidebar: #0f172a;
    --bg-rail: #0f172a;
    --text-main: #ffffff;
    --text-muted: #e2e8f0;
    --text-light: #94a3b8;
    --border: #1e293b;
    --shadow-card: 0 4px 6px -1px rgba(0,0,0,0.4);
    
    /* Overrides for specific elements in dark mode */
    --primary: #818cf8; /* Lighter indigo for better visibility in dark mode */
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden; /* We handle scrolling in specific containers */
    height: 100vh;
}

.dashboard-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 1. Navigation Rail (Fixed Left) */
.nav-rail {
    width: var(--rail-width);
    background: var(--bg-rail);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    color: var(--text-main);
    z-index: 100;
    border-right: 1px solid var(--border);
}

.nav-logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3rem;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.nav-links {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-item {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.nav-item.active {
    background: var(--text-main);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.nav-item span { font-size: 26px; }

/* 2. Sidebar Panel (Configuration) */
.sidebar-panel {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 90;
    box-shadow: var(--shadow-card);
}

.panel-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.social-links {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.social-links a {
    color: var(--text-light);
    font-size: 1.1rem;
    transition: var(--transition);
    opacity: 0.6;
}

.social-links a:hover {
    color: var(--text-main);
    opacity: 1;
    transform: translateY(-2px);
}

.dev-name {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-light);
    opacity: 0.4;
    letter-spacing: 0.1em;
    margin-top: 1rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.panel-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.panel-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    background: var(--bg-sidebar);
}

/* Form Styles */
.input-group { margin-bottom: 1.5rem; }
.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

select, textarea {
    width: 100%;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text-main);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

select:focus, textarea:focus { border-color: var(--primary); }
textarea { height: 100px; resize: none; }

.customization-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.color-picker-wrapper {
    height: 45px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

input[type="color"] {
    width: 150%;
    height: 150%;
    border: none;
    margin: -10%;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.btn-primary { 
    background: #000000; 
    color: #ffffff; 
    width: 100%; 
    position: relative;
    z-index: 1;
    overflow: hidden;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: none;
    font-weight: 700;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: -150%;
    left: -150%;
    width: 400%;
    height: 400%;
    background: conic-gradient(
        #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000
    );
    animation: rotate-border 3s linear infinite;
    z-index: -2;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 2px; /* This creates the STROKE thickness */
    background: #000000;
    border-radius: 10px;
    z-index: -1;
    transition: var(--transition);
}

.btn-primary:hover::after {
    background: #111111;
}

.btn-primary:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

@keyframes rotate-border {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes glow-pulse {
    /* Kept for reference but not applied to primary anymore */
    0% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.7), 0 0 30px rgba(59, 130, 246, 0.5); }
    100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.4); }
}

.btn-secondary { background: var(--bg-app); border: 1px solid var(--border); color: var(--text-main); }
.btn-secondary:hover { background: var(--border); }

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

/* 3. Main Viewport */
.main-viewport {
    flex: 1;
    padding: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewport-card {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.viewport-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.viewport-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    font-size: 2.25rem;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
}

.title-meta h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.status-badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    background: var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.preview-stage {
    flex: 1;
    background: #fff;
    border-radius: 36px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    min-height: 400px;
}

.stage-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.5;
    background-image: radial-gradient(var(--border) 1px, transparent 1px);
    background-size: 24px 24px;
}

[data-theme="dark"] .preview-stage { 
    background: #0f172a; 
}

.empty-stage {
    position: relative;
    z-index: 1;
    text-align: center;
    color: var(--text-light);
    animation: fadeInDown 0.8s ease-out;
}

.stage-icon {
    width: 90px;
    height: 90px;
    border-radius: 24px;
    background: #ffffff;
    color: #000000; /* Force black for white bg */
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.stage-icon span { font-size: 44px; }

.stage-hint {
    margin-top: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: rgba(16, 185, 129, 0.08);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.stage-hint span { font-size: 1.1rem; }

#barcodeContainer {
    background: #fff;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-float);
    z-index: 5;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#barcodeSvg {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 250px;
}

#qrCanvas {
    max-width: 90%;
    max-height: 380px;
    width: auto !important;
    height: auto !important;
    border-radius: 12px;
    z-index: 5;
    box-shadow: var(--shadow-float);
}

/* Action Footer Below Preview */
.viewport-actions {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    background: var(--bg-sidebar);
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-card);
}

.action-divider {
    width: 1px;
    height: 30px;
    background: var(--border);
}

.download-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.download-grid .btn {
    background: #000000;
    color: #ffffff;
    border: none;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
}

.download-grid .btn:hover {
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    transform: translateY(-1px);
}

[data-theme="dark"] .viewport-actions {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] select, [data-theme="dark"] textarea {
    background: #111827;
    border-color: #374151;
    color: #ffffff;
}

[data-theme="dark"] .history-item {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .nav-item.active {
    background: #ffffff;
    color: #000000;
}

/* Logo Upload Customization */
.logo-upload-box {
    margin-top: 1rem;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    background: var(--bg-app);
}

.logo-upload-box:hover { border-color: var(--primary); }
.logo-upload-box span { color: var(--primary); }
.logo-upload-box.has-image { background: rgba(16, 185, 129, 0.05); border-color: var(--accent); }

/* Bulk Upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 20px;
    padding: 3rem 1rem;
    text-align: center;
    cursor: pointer;
}

.upload-area:hover { background: var(--bg-app); }

.bulk-instructions {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-app);
    border-radius: 14px;
}

.bulk-instructions h4 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.bulk-instructions ul { padding-left: 1.25rem; font-size: 0.8rem; color: var(--text-muted); }

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-app);
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover { border-color: var(--primary); transform: translateX(4px); }

/* Helper */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 1100px) {
    --sidebar-width: 320px;
}

@media (max-width: 850px) {
    .dashboard-container { flex-direction: column; }
    .nav-rail { width: 100%; height: 60px; flex-direction: row; padding: 0 1rem; }
    .nav-logo { margin-bottom: 0; margin-right: 1.5rem; width: 32px; height: 32px; }
    .nav-links { flex-direction: row; }
    .sidebar-panel { width: 100%; height: auto; }
    .main-viewport { padding: 1rem; }
}

/* Bulk Progress Overlay */
.bulk-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 32px;
    z-index: 10;
}

.bulk-progress-card {
    width: 400px;
    padding: 2rem;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow-float);
    text-align: center;
}

.progress-bar-container {
    height: 12px;
    background: var(--bg-app);
    border-radius: 10px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* Vertical Marquee Styling */
.vertical-marquee {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 60px;
    background: #ffffff;
    border-left: 1px solid var(--border);
    display: flex;
    justify-content: center;
    overflow: hidden;
    z-index: 9999;
}

.marquee-content {
    display: flex;
    flex-direction: column;
    animation: scroll-vertical 15s linear infinite;
    padding: 2rem 0;
}

.marquee-content span {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 0.3rem;
    color: #000000;
    opacity: 1;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    margin: 3rem 0;
    white-space: nowrap;
}

@keyframes scroll-vertical {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

[data-theme="dark"] .vertical-marquee {
    background: #020617;
    border-color: #1e293b;
}

[data-theme="dark"] .marquee-content span {
    color: #ffffff;
    opacity: 1;
}

/* Mobile Bottom Navigation (Floating Pill Style) */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    left: 1rem;
    right: 1rem;
    height: 70px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 24px;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.mobile-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    height: 54px;
    width: 65px;
    background: transparent;
    color: #64748b;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 18px;
}

.mobile-nav .nav-item span:first-child {
    font-size: 1.5rem;
}

.mobile-nav .nav-item span:last-child {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}

.mobile-nav .nav-item.active {
    color: #000000;
    background: rgba(0, 0, 0, 0.05);
}

.mobile-nav .nav-item.active span:first-child {
    transform: translateY(-2px);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .nav-rail, .vertical-marquee {
        display: none !important;
    }

    .dashboard-container {
        flex-direction: column;
    }

    .main-viewport {
        flex-direction: column;
        height: 100vh;
        overflow-y: auto;
    }

    .input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1.5rem;
        flex-shrink: 0;
        background: var(--bg-app);
    }

    .preview-viewport {
        padding: 1.5rem;
        padding-bottom: 8rem; /* Extra space for floating nav */
    }

    .mobile-nav {
        display: flex;
    }
}

/* Dark Mode Fixes for Mobile */
[data-theme="dark"] .mobile-nav {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .mobile-nav .nav-item {
    color: #94a3b8;
}

[data-theme="dark"] .mobile-nav .nav-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}
