/* ═══════════════════════════════════════════════════
   CSIFACT PrinterTestLab — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
    /* Color palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #1e2440;
    --bg-input: #0f1525;
    --border-color: rgba(99, 102, 241, 0.15);
    --border-active: rgba(99, 102, 241, 0.4);

    /* Accent colors */
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.2);
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-cyan: #06b6d4;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(99, 102, 241, 0.05);
    --shadow-btn: 0 2px 12px rgba(99, 102, 241, 0.3);
}

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

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ═══ HEADER ═══ */
.app-header {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo-section h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-green);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ═══ CONTAINER ═══ */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ═══ CARDS ═══ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s ease;
}

.card:hover {
    border-color: var(--border-active);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.card-header:hover {
    background: var(--bg-card-hover);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.chevron {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.3s ease;
}

.card-body {
    padding: 0 20px 20px;
    animation: slideDown 0.3s ease;
}

.card-body.hidden {
    display: none;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.4;
}

/* ═══ SETTINGS ═══ */
.setting-group {
    margin-bottom: 16px;
}

.setting-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.toggle-group {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(6, 182, 212, 0.1));
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.toggle-icon {
    margin-right: 4px;
}

.input-field {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
    transition: border-color 0.2s;
    outline: none;
}

.input-field:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* ═══ TEST GRID ═══ */
.test-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.test-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.test-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.test-btn:active {
    transform: scale(0.97);
}

.btn-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.btn-label {
    font-size: 13px;
    font-weight: 600;
}

.btn-desc {
    font-size: 10px;
    color: var(--text-muted);
}

/* Test button colors */
.test-left { border-color: rgba(99, 102, 241, 0.3); }
.test-left:hover { background: rgba(99, 102, 241, 0.1); border-color: var(--accent-primary); }

.test-center { border-color: rgba(6, 182, 212, 0.3); }
.test-center:hover { background: rgba(6, 182, 212, 0.1); border-color: var(--accent-cyan); }

.test-bold { border-color: rgba(245, 158, 11, 0.3); }
.test-bold:hover { background: rgba(245, 158, 11, 0.1); border-color: var(--accent-orange); }

.test-mixed { border-color: rgba(16, 185, 129, 0.3); }
.test-mixed:hover { background: rgba(16, 185, 129, 0.1); border-color: var(--accent-green); }

.test-qr { border-color: rgba(168, 85, 247, 0.3); }
.test-qr:hover { background: rgba(168, 85, 247, 0.1); border-color: #a855f7; }

.test-image { border-color: rgba(239, 68, 68, 0.3); }
.test-image:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--accent-red); }

.test-separator { border-color: rgba(148, 163, 184, 0.3); }
.test-separator:hover { background: rgba(148, 163, 184, 0.1); border-color: var(--text-secondary); }

.test-sizes { border-color: rgba(236, 72, 153, 0.3); }
.test-sizes:hover { background: rgba(236, 72, 153, 0.1); border-color: #ec4899; }

/* ═══ TICKET PREVIEW ═══ */
.ticket-preview {
    background: #fff;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.preview-header {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-body {
    padding: 16px;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
}

/* ═══ BUTTONS ═══ */
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn:active {
    transform: scale(0.97);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    box-shadow: var(--shadow-btn);
}

.action-btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
}

.action-btn.secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.action-btn.secondary:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.action-btn.accent {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    min-width: 120px;
    flex: 0;
}

.action-btn.accent:hover {
    background: linear-gradient(135deg, #34d399, var(--accent-green));
}

/* ═══ INPUT GROUP ═══ */
.input-group {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.input-group .input-field {
    flex: 1;
}

/* ═══ RAW VIEWER ═══ */
.raw-viewer {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.raw-viewer code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent-cyan);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

/* ═══ DATA SUMMARY ═══ */
.data-summary {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.6;
}

.data-summary strong {
    color: var(--accent-green);
}

/* ═══ TEXTAREA ═══ */
.textarea-field {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--accent-cyan);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    resize: vertical;
    outline: none;
    line-height: 1.5;
    margin-bottom: 8px;
}

.textarea-field:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ═══ ERROR / HIDDEN ═══ */
.hidden {
    display: none !important;
}

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: #fca5a5;
    font-size: 13px;
    margin-top: 12px;
}

/* ═══ TOAST ═══ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    border: 1px solid var(--border-active);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-xl);
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    display: block !important;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-card));
}

.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-card));
}

/* ═══ FOOTER ═══ */
.app-footer {
    text-align: center;
    padding: 24px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 400px) {
    .test-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .test-btn {
        padding: 12px 8px;
    }

    .btn-icon {
        font-size: 20px;
    }

    .header-content {
        flex-direction: row;
    }
}

/* ═══ ANIMATIONS ═══ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.card {
    animation: fadeIn 0.4s ease;
}

/* Stagger animation */
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

/* Loading spinner on buttons */
.action-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}
.action-btn.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
