/* ============================================
   PRINTODROP — Design System
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   SCREEN MANAGEMENT
   ============================================ */

.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SPLASH SCREEN
   ============================================ */

#splash-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.splash-content {
    max-width: 480px;
    width: 100%;
}

#splash-screen .logo {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

#splash-screen h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2.5rem;
    line-height: 1.7;
}

.role-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.role-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.role-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.4);
}

.role-btn .icon {
    font-size: 2.5rem;
}

.role-btn .label {
    font-size: 1.2rem;
    font-weight: 600;
}

.role-btn .sub {
    font-size: 0.85rem;
    opacity: 0.8;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(0,0,0,0.2);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ============================================
   HEADERS
   ============================================ */

.shop-header, .customer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.shop-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-small {
    font-size: 1.5rem;
}

.badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    background: var(--primary);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-back {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connection-status {
    font-size: 0.85rem;
    font-weight: 600;
}

.connection-status.connected {
    color: var(--success);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary, .btn-secondary, .btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.5);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
}

.btn-ghost.danger {
    color: var(--danger);
}

.btn-ghost:hover {
    background: var(--surface-2);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: var(--radius);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: var(--transition);
}

.btn-icon:hover {
    opacity: 1;
}

.btn-scan {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    background: var(--surface);
    border: 2px dashed var(--primary);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.btn-scan:hover {
    background: rgba(99, 102, 241, 0.05);
}

.scan-icon {
    font-size: 3rem;
}

/* ============================================
   SHOPKEEPER SCREENS
   ============================================ */

.shop-body {
    flex: 1;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.qr-section {
    text-align: center;
    margin-bottom: 2rem;
}

.qr-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.qr-container {
    position: relative;
    display: inline-block;
    padding: 1.5rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
}

#qr-canvas {
    display: block;
}

.qr-pulse {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    border: 3px solid var(--primary);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.05); opacity: 0; }
    100% { transform: scale(1); opacity: 0.5; }
}

.connection-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.connection-code code {
    background: var(--surface-2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.1em;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

.status-indicator .dot.waiting {
    background: var(--warning);
}

.status-indicator .dot.connected {
    background: var(--success);
    animation: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.shop-instructions {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.shop-instructions h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.shop-instructions ol {
    padding-left: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 2;
}

/* File Preview Section */
.file-preview-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.file-preview-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.file-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: var(--radius-sm);
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.file-preview-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Print Settings */
.print-settings {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.print-settings h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.setting {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting select, .setting input {
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background: white;
}

.number-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.number-input button {
    width: 36px;
    height: 36px;
    background: var(--surface-2);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-input input {
    width: 50px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0.5rem;
    font-weight: 600;
}

.print-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ============================================
   CUSTOMER SCREENS
   ============================================ */

.customer-body {
    flex: 1;
    padding: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.customer-body h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.or-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.or-divider::before, .or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.code-input-section {
    display: flex;
    gap: 0.75rem;
}

.code-input-section input {
    flex: 1;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.code-input-section input:focus {
    outline: none;
    border-color: var(--primary);
}

.privacy-note {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #166534;
}

.privacy-note span {
    font-size: 1.5rem;
}

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.file-drop-zone:hover, .file-drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
}

.drop-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.file-types {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.selected-files {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.selected-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.selected-file-item .remove {
    margin-left: auto;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    background: none;
    border: none;
}

.customer-actions {
    text-align: center;
}

.privacy-promise {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================
   CAMERA OVERLAY
   ============================================ */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.overlay.active {
    display: flex;
}

.camera-container {
    position: relative;
    width: 90%;
    max-width: 400px;
    aspect-ratio: 1;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
}

.scan-frame {
    position: absolute;
    inset: 10%;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
}

.scan-frame .corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
}

.scan-frame .corner.tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; }
.scan-frame .corner.tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; }
.scan-frame .corner.bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; }
.scan-frame .corner.br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; }

.scan-hint {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    font-size: 0.9rem;
}

.btn-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ============================================
   CENTER CONTENT (Loading/Complete screens)
   ============================================ */

.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    max-width: 400px;
    margin: 0 auto;
}

.center-content h2 {
    font-size: 1.5rem;
    margin: 1rem 0 0.5rem;
}

.center-content p {
    color: var(--text-secondary);
}

/* Print Animation */
.print-animation {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.printer-icon {
    font-size: 4rem;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.paper-stack {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
}

.paper {
    width: 50px;
    height: 60px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 2px;
    margin: 0 auto;
    animation: printPaper 1.5s infinite;
    position: absolute;
    left: 5px;
}

.paper:nth-child(1) { animation-delay: 0s; }
.paper:nth-child(2) { animation-delay: 0.5s; }
.paper:nth-child(3) { animation-delay: 1s; }

@keyframes printPaper {
    0% { transform: translateY(0); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateY(80px); opacity: 0; }
}

/* Transfer Animation */
.transfer-animation {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.transfer-animation .device {
    font-size: 3rem;
}

.transfer-line {
    width: 100px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.transfer-packet {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    top: -4px;
    animation: transferPacket 1.5s infinite;
}

.transfer-packet:nth-child(1) { animation-delay: 0s; }
.transfer-packet:nth-child(2) { animation-delay: 0.5s; }
.transfer-packet:nth-child(3) { animation-delay: 1s; }

@keyframes transferPacket {
    0% { left: -12px; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

/* Success Animation */
.success-animation {
    font-size: 4rem;
    animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.speed {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Status Steps */
.status-steps {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.step {
    padding: 0.5rem 1rem;
    background: var(--surface-2);
    border-radius: 50px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.step.done {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.step.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    animation: pulse 2s infinite;
}

/* Completion Details */
.completion-details, .complete-details, .waiting-info {
    background: var(--surface-2);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

.completion-details p, .complete-details p, .waiting-info p {
    margin: 0.5rem 0;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--text);
    color: white;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-20px); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .shop-body, .customer-body {
        padding: 1rem;
    }
    
    #splash-screen h1 {
        font-size: 2rem;
    }
    
    .role-btn {
        padding: 1.25rem;
    }
}

/* Print-specific styles */
@media print {
    .no-print { display: none !important; }
}