/* Modern CSS variables and reset */
:root {
    --bg-primary: #0b0d19;
    --bg-surface: rgba(20, 24, 46, 0.65);
    --bg-surface-hover: rgba(30, 36, 68, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(56, 189, 248, 0.15);
    
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --primary-glow: rgba(56, 189, 248, 0.4);
    
    --danger: #f87171;
    --danger-hover: #ef4444;
    
    --success: #34d399;
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--color-text);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Beautiful Animated Ambient Glow Backgrounds */
.bg-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
    animation: pulse 12s infinite alternate ease-in-out;
}

.bg-glow-1 {
    background: radial-gradient(circle, #38bdf8 0%, rgba(56, 189, 248, 0) 70%);
    top: -10%;
    left: -10%;
}

.bg-glow-2 {
    background: radial-gradient(circle, #c084fc 0%, rgba(192, 132, 252, 0) 70%);
    bottom: -10%;
    right: -10%;
    animation-delay: -6s;
}

@keyframes pulse {
    0% { transform: scale(1) translate(0, 0); }
    100% { transform: scale(1.15) translate(50px, 30px); }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 520px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

/* Screen Transitions */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    width: 100%;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    padding: 2.5rem;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Auth / Lock Card specific */
.auth-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.brand {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-wrapper {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.3);
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: white;
}

.brand h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #d8b4fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Forms and Inputs */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: rgba(15, 23, 42, 0.8);
}

.monospace-input {
    font-family: var(--font-mono) !important;
    letter-spacing: 0.5px;
}

.btn-toggle-password {
    position: absolute;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.25rem;
}

.btn-toggle-password:hover {
    color: var(--color-text);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    text-decoration: none;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0284c7 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #0369a1 100%);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35);
    transform: translateY(-1px);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.btn-danger:hover {
    background: var(--danger-hover);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-icon-only {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
}

.btn-icon-only:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.08);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

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

.inline-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-right: 4px;
}

.auth-footer {
    margin-top: 2rem;
    text-align: center;
}

.security-note {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Dashboard Screen layout */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo-icon-small {
    color: var(--primary);
    width: 28px;
    height: 28px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Search and Action Bar */
.search-bar-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.search-input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.search-input-wrapper input {
    padding-left: 3rem;
    padding-right: 2.75rem;
    height: 100%;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--color-text-muted);
    width: 18px;
    height: 18px;
}

.btn-clear-search {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.btn-clear-search:hover {
    color: var(--color-text);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.empty-icon-wrapper {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--color-text-muted);
}

.empty-icon-wrapper i {
    width: 32px;
    height: 32px;
}

.empty-state h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.empty-state p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    max-width: 280px;
    line-height: 1.5;
}

/* Token List and Cards */
.token-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.token-card {
    background: var(--bg-surface);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.token-card:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(56, 189, 248, 0.25);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.token-info {
    flex-grow: 1;
    min-width: 0; /* Ensures truncation works */
}

.token-issuer {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-label {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.token-code-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.token-code {
    font-family: var(--font-mono);
    font-size: 1.85rem;
    font-weight: 700;
    color: white;
    letter-spacing: 1px;
}

.token-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Countdown SVG Timer styles */
.timer-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
}

.timer-ring {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.timer-ring-circle-bg {
    stroke: rgba(255, 255, 255, 0.05);
}

.timer-ring-circle {
    stroke: var(--primary);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear, stroke var(--transition-fast);
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* Red indicator when timer is low (<6s) */
.timer-low .timer-ring-circle {
    stroke: var(--danger);
}
.timer-low .timer-text {
    color: var(--danger);
}

.btn-delete-token {
    background: none;
    border: none;
    color: var(--color-text-muted);
    opacity: 0;
    cursor: pointer;
    padding: 0.25rem;
    transition: all var(--transition-fast);
}

.token-card:hover .btn-delete-token {
    opacity: 1;
}

.btn-delete-token:hover {
    color: var(--danger);
}

/* Modal Overlay & Modal Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 6, 15, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    transition: opacity var(--transition-normal);
    padding: 1.5rem;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal {
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
    padding: 0;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.btn-close-modal:hover {
    color: var(--color-text);
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--color-text-muted);
    padding: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.modal-body {
    padding: 1.75rem;
    max-height: 70vh;
    overflow-y: auto;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Scanner styles */
.qr-scanner-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#qr-reader {
    width: 100%;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
    border: 1px solid var(--border-color) !important;
    background: black;
}

/* Style overrides for html5-qrcode standard layout */
#qr-reader__dashboard {
    padding: 1rem !important;
    background: var(--bg-surface) !important;
    border-top: 1px solid var(--border-color) !important;
}

#qr-reader button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: white;
    transition: all var(--transition-fast);
}

#qr-reader button:hover {
    background: var(--primary-hover);
}

.scanner-fallback {
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

.scanner-fallback p {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.file-input {
    display: none;
}

/* Settings Sections */
.settings-section {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.settings-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.text-danger {
    color: var(--danger) !important;
}

/* Advanced Settings Dropdown */
.advanced-trigger-wrapper {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Toast Message */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--primary-glow);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), 0 0 15px rgba(56, 189, 248, 0.15);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    pointer-events: none;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    color: var(--success);
    width: 18px;
    height: 18px;
}

/* Dynamic Copy Anim on Code */
.copied-flash::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(56, 189, 248, 0.15);
    animation: flash 0.6s ease-out;
    pointer-events: none;
}

@keyframes flash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Error Shake Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.shake {
    animation: shake 0.5s ease-in-out;
}
