:root {
    /* Color Palette */
    --bg-primary: #0f172a; /* depth */
    --bg-secondary: #1e293b;
    --brand-primary: #3b82f6;
    --brand-primary-hover: #2563eb;
    --brand-secondary: #8b5cf6;
    --brand-secondary-hover: #7c3aed;
    --brand-gradient: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(59, 130, 246, 0.5);
    
    /* Semantic Colors */
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    
    /* Layout Tokens */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.2);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    position: relative;
    overflow-x: hidden;
}

/* Background Gradients/Blobs */
.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}
.blob-1 {
    top: -10%;
    right: -5%;
    width: 600px;
    height: 600px;
    background: var(--brand-secondary);
}
.blob-2 {
    bottom: -20%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--brand-primary);
}
.blob-3 {
    top: 40%;
    left: 30%;
    width: 300px;
    height: 300px;
    background: rgba(16, 185, 129, 0.2); /* faint emerald */
}

/* App Container (Glass) */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.app-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2rem 2.5rem;
    border-bottom: var(--border-color) solid 1px;
}
.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.logo-icon svg {
    width: 28px;
    height: 28px;
}
.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.app-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Tabs */
.tabs {
    display: flex;
    padding: 0 2.5rem;
    border-bottom: var(--border-color) solid 1px;
    background-color: rgba(15, 23, 42, 0.3);
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}
.tab-btn:hover {
    color: var(--text-main);
}
.tab-btn.active {
    color: var(--brand-primary);
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--brand-primary);
    border-radius: 3px 3px 0 0;
}

/* Tab Content Areas */
.tab-content {
    padding: 2.5rem;
}
.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}
.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Single Mode Layout */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

/* Form Styling */
.form-section {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-section:last-child {
    margin-bottom: 0;
}
.form-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    flex: 1;
}
.input-group:last-child { margin-bottom: 0; }
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-row .input-group { margin-bottom: 0; }

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}
.required { color: var(--error); margin-left: 2px;}

input[type="text"], input[type="url"], input[type="number"], select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    width: 100%;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}
input::placeholder { color: #475569; }

/* Readonly Input for Generated URL */
.url-output-box {
    margin-bottom: 1.5rem;
}
.url-action-group {
    display: flex;
    gap: 0.5rem;
}
.url-action-group input {
    background: rgba(15, 23, 42, 0.6);
    border-color: var(--border-color);
    color: var(--brand-primary);
    font-family: monospace;
    font-size: 0.9rem;
}
.btn-icon {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
    background: var(--bg-secondary);
}

/* Checkbox Toggle Default */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    margin: 0;
}
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }

/* Validation Warning */
.validation-warning {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--warning);
    display: none;
    padding: 0.5rem;
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--warning);
}

/* Validation Warning Animation Frame */
.highlight-warn {
    animation: flashWarn 1s;
}
@keyframes flashWarn {
    0% { background-color: var(--warning-bg); border-color: var(--warning); }
    100% { background-color: transparent; border-color: var(--border-color); }
}

/* Preview Side */
.preview-container {
    background: rgba(15, 23, 42, 0.2);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}
.preview-container h3 {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    text-align: left;
}
.qr-preview-box {
    background: white;
    min-height: 250px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.placeholder-text {
    color: #94a3b8;
    text-align: center;
    font-size: 0.95rem;
}
#qrCodeContainer {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
#qrCodeContainer img {
    max-width: 100%;
    height: auto;
}

/* Buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: auto;
}
.btn {
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.btn:active:not(:disabled) {
    transform: scale(0.98);
}
.btn-primary {
    background: var(--brand-primary);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-primary-hover); }

.btn-primary-alt {
    background: var(--brand-secondary);
    color: white;
}
.btn-primary-alt:hover:not(:disabled) { background: var(--brand-secondary-hover); }

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.05);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-outline:hover:not(:disabled) {
    border-color: var(--text-muted);
    background: rgba(255,255,255,0.02);
}
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.85rem;}

.btn-group {
    display: flex;
    gap: 1rem;
}

/* Batch Mode */
.flex-col { display: flex; flex-direction: column; }
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 4rem 2rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.3);
    transition: all 0.2s;
    cursor: pointer;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.05);
}
.upload-icon {
    color: var(--brand-primary);
    margin-bottom: 1rem;
}
.upload-area h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.drop-text { color: var(--text-muted); margin-bottom: 1rem; }
.hidden-input { display: none; }
.tag {
    background: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    color: var(--brand-secondary);
}
.subtitle { font-size: 0.9rem; color: var(--text-muted); }
.sample-link {
    display: inline-block;
    color: var(--brand-primary);
    text-decoration: none;
    font-size: 0.9rem;
}
.sample-link:hover { text-decoration: underline; }

.batch-preview {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-top: 1.5rem;
}
.batch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.highlight-badge {
    background: var(--success-bg);
    color: var(--success);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
}
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
th {
    background: rgba(30, 41, 59, 0.8);
    position: sticky;
    top: 0;
    font-weight: 600;
    color: var(--text-muted);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td.error-cell {
    color: var(--error);
    background: var(--error-bg);
}

.batch-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.row-align { flex-direction: row; align-items: center; gap: 1rem; }
.row-align label { margin-bottom: 0; }
.small-select { width: auto; min-width: 150px; }

/* Progress Bar */
.progress-box {
    background: rgba(15, 23, 42, 0.5);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.progress-bar-container {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.progress-bar {
    height: 100%;
    background: var(--brand-gradient);
    width: 0%;
    transition: width 0.2s ease;
}
.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Error Report */
.error-report {
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
}
.error-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--error);
    margin-bottom: 0.5rem;
}
.error-desc {
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 1rem;
}
#errorList {
    font-size: 0.85rem;
    padding-left: 1.5rem;
    max-height: 150px;
    overflow-y: auto;
    color: var(--text-muted);
    font-family: monospace;
}

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-weight: 500;
    z-index: 100;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
    .split-layout { grid-template-columns: 1fr; }
    .app-header { flex-direction: column; align-items: flex-start; gap: 1rem;}
    .batch-actions { flex-direction: column; align-items: stretch; gap: 1rem; }
    .btn-group { justify-content: stretch; }
}
