/* ===========================================
   THEME: Glass Compact (No-Scroll)
   Accent: Purple gradient (#7c3aed -> #6366f1)
   Optimized: Full viewport, fluid scaling
   =========================================== */

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

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --primary-glow: rgba(59, 130, 246, 0.4);
    --error-color: #ef4444;
    --success-color: #22c55e;
    --background: #0f172a;
    --background-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --surface-solid: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-glow: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(20px);
    --radius: clamp(12px, 2vmin, 16px);
    --radius-sm: clamp(8px, 1.5vmin, 12px);
    --radius-full: 9999px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
    background: var(--background-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Animated background orbs - subtle */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    pointer-events: none;
    z-index: -1;
}

body::before {
    width: 40vmin;
    height: 40vmin;
    background: #3b82f6;
    top: -10vmin;
    right: -10vmin;
    animation: float 20s ease-in-out infinite;
}

body::after {
    width: 30vmin;
    height: 30vmin;
    background: #1d4ed8;
    bottom: -5vmin;
    left: -5vmin;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, 20px) scale(1.05); }
}

/* Screen takes full viewport */
.screen {
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: clamp(0.5rem, 2vmin, 1rem);
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Container - Full height flexbox */
.container {
    width: 100%;
    max-width: min(420px, 95vw);
    height: 100%;
    background: var(--surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: clamp(1rem, 3vmin, 1.5rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-glow), transparent);
}

/* HEADER */
header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: clamp(0.5rem, 1.5vmin, 0.75rem);
    margin-bottom: clamp(0.5rem, 1.5vmin, 0.75rem);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

header h1 {
    font-size: clamp(1rem, 2.5vmin, 1.25rem);
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Form takes minimum needed space */
#generate-form {
    flex-shrink: 0;
}

/* Form Elements - Compact */
.form-group {
    margin-bottom: clamp(1rem, 2.5vmin, 1.25rem);
}

label {
    display: block;
    font-size: clamp(0.6875rem, 1.8vmin, 0.875rem);
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: clamp(0.25rem, 0.75vmin, 0.375rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: clamp(0.625rem, 1.75vmin, 1rem) clamp(0.875rem, 2.25vmin, 1.25rem);
    font-size: clamp(1rem, 2.75vmin, 1.125rem);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-solid);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

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

select option {
    background: #1e293b;
    color: white;
}

small {
    display: block;
    font-size: clamp(0.625rem, 1.5vmin, 0.75rem);
    color: var(--text-muted);
    margin-top: clamp(0.25rem, 0.625vmin, 0.375rem);
}

/* Button Group - Separate Pills */
.btn-group {
    display: flex;
    gap: clamp(0.5rem, 1.5vmin, 0.75rem);
    flex-shrink: 0;
}

.btn-generate {
    flex: 1;
    padding: clamp(0.625rem, 1.75vmin, 0.875rem) clamp(0.5rem, 1.25vmin, 0.75rem);
    font-size: clamp(0.75rem, 2vmin, 0.9375rem);
    font-weight: 600;
    background: var(--surface-solid);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-generate:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-generate:active,
.btn-generate.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Result - Grows to fill remaining space */
.result {
    flex: 1;
    min-height: 0;
    margin-top: clamp(0.75rem, 2vmin, 1.25rem);
    padding: clamp(0.75rem, 2vmin, 1.25rem);
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
    overflow: hidden;
}

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

.result > label {
    flex-shrink: 0;
    margin-bottom: clamp(0.5rem, 1.25vmin, 0.75rem);
    font-size: clamp(0.75rem, 2vmin, 0.875rem);
}

.password-display {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vmin, 0.75rem);
    flex-shrink: 0;
}

.password-display code {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: clamp(1.125rem, 4vmin, 1.5rem);
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: clamp(0.625rem, 1.75vmin, 1rem) clamp(0.875rem, 2.25vmin, 1.25rem);
    background-color: var(--surface-solid);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    letter-spacing: 0.04em;
    word-break: break-all;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

.btn-primary {
    width: 100%;
    padding: clamp(0.75rem, 2vmin, 1rem);
    font-size: clamp(0.875rem, 2.25vmin, 1rem);
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-copy {
    padding: clamp(0.5rem, 1.25vmin, 0.625rem);
    background: var(--surface-solid);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.btn-copy:hover {
    background: var(--surface-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-copy svg {
    width: clamp(16px, 4vmin, 20px);
    height: clamp(16px, 4vmin, 20px);
}

/* Feedback */
.feedback {
    font-size: clamp(0.75rem, 1.75vmin, 0.875rem);
    color: var(--success-color);
    margin-top: clamp(0.375rem, 1vmin, 0.5rem);
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
}

/* Barcode - Takes remaining space in result area */
.barcode-container {
    flex: 1;
    min-height: 0;
    margin-top: clamp(0.5rem, 1.5vmin, 0.875rem);
    padding: clamp(0.5rem, 1.5vmin, 0.875rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.barcode-container::after {
    content: 'Tap to scan';
    position: absolute;
    bottom: clamp(0.375rem, 1.25vmin, 0.625rem);
    font-size: clamp(0.625rem, 1.5vmin, 0.75rem);
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.barcode-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-glow);
}

.barcode-container svg {
    max-width: 100%;
    max-height: calc(100% - 1.5rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Error */
.error {
    color: var(--error-color);
    font-size: clamp(0.6875rem, 1.75vmin, 0.875rem);
    text-align: center;
    margin-top: clamp(0.5rem, 1.5vmin, 0.75rem);
    padding: clamp(0.5rem, 1.25vmin, 0.75rem);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
}

/* Login Screen - Also compact */
#login-screen .container {
    justify-content: center;
}

#login-screen h1 {
    font-size: clamp(1.25rem, 4vmin, 1.625rem);
    font-weight: 700;
    margin-bottom: clamp(0.25rem, 1vmin, 0.5rem);
    text-align: center;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: clamp(1rem, 3vmin, 1.5rem);
    font-size: clamp(0.8125rem, 2vmin, 0.9375rem);
}

/* Biometric Button */
.btn-biometric {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 1.5vmin, 0.75rem);
    margin-top: clamp(1rem, 2.5vmin, 1.25rem);
    padding: clamp(0.75rem, 2vmin, 1rem);
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
}

.btn-biometric:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-biometric svg {
    width: clamp(18px, 4vmin, 24px);
    height: clamp(18px, 4vmin, 24px);
    flex-shrink: 0;
}

.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

/* Biometric button needs relative positioning for absolute × */
.btn-biometric {
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* Close button to disable biometric - absolutely positioned right */
.biometric-disable {
    position: absolute;
    right: clamp(0.5rem, 1.5vmin, 0.75rem);
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem 0.5rem;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.biometric-disable:hover,
.biometric-disable:active {
    opacity: 1;
}

/* Ensure btn-success always has white text in all states */
.btn-success,
.btn-success:hover,
.btn-success:focus,
.btn-success:active,
.btn-biometric.btn-success,
.btn-biometric.btn-success:hover,
.btn-biometric.btn-success:focus,
.btn-biometric.btn-success:active {
    color: white;
    outline: none;
}

/* Version */
.version {
    display: none; /* Hidden in compact mode */
}

.screen-with-footer {
    /* No special handling needed */
}

/* Fullscreen barcode overlay */
.barcode-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.barcode-fullscreen svg {
    max-width: 90vw;
    max-height: 60vh;
}

.stacked-barcodes {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(1.5rem, 4vmin, 2.5rem);
}

.stacked-barcodes svg {
    max-width: 90vw;
}

.btn-close {
    position: absolute;
    top: clamp(0.75rem, 2vmin, 1.5rem);
    right: clamp(0.75rem, 2vmin, 1.5rem);
    padding: clamp(0.5rem, 1.5vmin, 0.75rem);
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: #18181b;
}

.btn-close:hover {
    background: #e4e4e7;
}

.barcode-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: clamp(0.75rem, 2vmin, 1.5rem);
}

.barcode-dots .dot {
    width: clamp(6px, 1.5vmin, 8px);
    height: clamp(6px, 1.5vmin, 8px);
    border-radius: var(--radius-full);
    background: #d4d4d8;
    transition: all 0.2s ease;
}

.barcode-dots .dot.active {
    background: var(--primary-color);
    width: clamp(18px, 4vmin, 24px);
}

/* PWA standalone - account for safe areas and rounded corners */
@supports (padding: max(0px)) {
    .screen {
        padding-top: max(clamp(0.5rem, 2vmin, 1rem), env(safe-area-inset-top));
        padding-bottom: max(clamp(1rem, 3vmin, 1.5rem), env(safe-area-inset-bottom));
        padding-left: max(clamp(0.5rem, 2vmin, 1rem), env(safe-area-inset-left));
        padding-right: max(clamp(0.5rem, 2vmin, 1rem), env(safe-area-inset-right));
    }
}

/* Extra bottom padding for devices with rounded corners */
@media (max-width: 480px) {
    .screen {
        padding-bottom: clamp(2.5rem, 8vmin, 4rem);
    }
}

/* Large screens - constrain width */
@media (min-width: 768px) {
    .container {
        max-width: 400px;
    }
}

/* Landscape mobile - extra compact */
@media (orientation: landscape) and (max-height: 500px) {
    .form-group {
        margin-bottom: clamp(0.375rem, 1.5vmin, 0.625rem);
    }

    small {
        display: none;
    }

    .result {
        margin-top: clamp(0.5rem, 1.5vmin, 0.75rem);
        padding: clamp(0.5rem, 1.5vmin, 0.75rem);
    }
}
