/* ==========================================================================
   THE UPI QR — Custom Premium CSS Styling
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --bg-dark: #07070a;
    --bg-card: rgba(18, 18, 29, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.18);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary-glow: rgba(99, 102, 241, 0.15);
    
    /* Neon Violet Theme (Default Active) */
    --accent: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #a78bfa, #8b5cf6);
    --accent-glow: rgba(139, 92, 246, 0.4);
    
    /* Layout properties */
    --font-ui: 'Outfit', 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --card-radius: 20px;
    --input-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

/* Ambient Glowing Background Backgrounds */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow-bg::before,
.glow-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    animation: rotateGlow 20s infinite linear;
}

.glow-bg::before {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #6366f1, #3b82f6);
    top: -10%;
    left: -10%;
}

.glow-bg::after {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #d946ef, #8b5cf6);
    bottom: -10%;
    right: -10%;
    animation-delay: -10s;
}

@keyframes rotateGlow {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); }
    33% { transform: translate(50px, 30px) rotate(120deg) scale(1.1); }
    66% { transform: translate(-20px, 50px) rotate(240deg) scale(0.9); }
    100% { transform: translate(0, 0) rotate(360deg) scale(1); }
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 24px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.2));
}

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

/* App Main Content Split Grid */
.app-content {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 32px;
    align-items: start;
    flex-grow: 1;
}

/* Card & Glassmorphic Primitives */
.card {
    border-radius: var(--card-radius);
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Control Panel / Inputs Form */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.section-title .icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.optional {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: lowercase;
}

/* Input Fields Container */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
}

.input-wrapper input {
    width: 100%;
    background: rgba(30, 30, 46, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 14px 14px 14px 44px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(30, 30, 46, 0.6);
    box-shadow: 0 0 15px var(--primary-glow);
}

button:focus-visible,
.custom-select-trigger:focus-visible,
.input-wrapper input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.input-wrapper input:focus + .input-icon {
    color: var(--accent);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.helper-text strong {
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* UPI Input Group Grid */
.upi-input-group {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 12px;
}

.username-wrapper input {
    font-family: var(--font-mono);
    letter-spacing: 0.2px;
}

/* Custom Select Dropdown Styling */
.custom-select-container {
    position: relative;
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.custom-select-trigger {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 30, 46, 0.45);
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 0 16px;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.custom-select-trigger:hover,
.custom-select-container.open .custom-select-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--primary-glow);
}

.chevron-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: var(--transition);
}

.custom-select-container.open .chevron-icon {
    transform: rotate(180deg);
    color: var(--accent);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 220px;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(15, 15, 23, 0.95);
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: var(--transition);
}

.custom-select-container.open .custom-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-option {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background: rgba(139, 92, 246, 0.15);
}

.custom-option.selected {
    background: rgba(139, 92, 246, 0.25);
}

.option-handle {
    font-weight: 600;
    color: var(--text-primary);
}

.option-bank {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* Scrollbar styling for selection list */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Switch & Toggle Group */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(30, 30, 46, 0.6);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: var(--transition);
}

.switch input:checked + .slider {
    background-color: rgba(139, 92, 246, 0.2);
    border-color: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.slider.round {
    border-radius: 34px;
}

.slider.round::before {
    border-radius: 50%;
}

/* Amount Input Area */
.amount-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    transition: var(--transition);
}

.amount-wrapper .currency-symbol {
    position: absolute;
    left: 18px;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.amount-wrapper input {
    padding-left: 40px;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.formatted-amount-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.formatted-badge {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--font-mono);
}

.words-badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-style: italic;
}

/* Card Style Theme Picker Group */
.theme-picker {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.more-button {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    font: 600 0.9rem var(--font-ui);
    cursor: pointer;
    transition: var(--transition);
}

.more-button:hover,
.more-button[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.12);
}

.additional-options[hidden] {
    display: none;
}

.theme-btn {
    border: 1px solid var(--border-color);
    border-radius: var(--input-radius);
    padding: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.theme-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    background: rgba(255, 255, 255, 0.03);
    transition: var(--transition);
}

.theme-btn:hover::before {
    opacity: 1;
}

.theme-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.06);
}

.theme-name {
    font-family: var(--font-ui);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* Right Panel: Preview Area */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    justify-content: center;
}

/* payment-card component dimensions */
.payment-card-wrapper {
    width: min(100%, 320px);
    aspect-ratio: 3 / 4;
    height: auto;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

#payment-card-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 16px;
}

/* Action Buttons Styles */
.action-buttons-group {
    display: flex;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.btn {
    flex: 1;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--input-radius);
    padding: 14px 20px;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--text-primary);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Footer Section */
.app-footer {
    text-align: center;
    padding: 40px 0 16px;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* Toast System Styling */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: rgba(18, 18, 26, 0.9);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 15px var(--accent-glow);
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) 3s forwards;
}

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

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

/* Animation Utilities */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Tablet / Desktop Responsiveness rules */
@media (max-width: 768px) {
    .app-container {
        padding: 16px;
    }
    
    .app-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .preview-panel {
        order: -1; /* Render card preview at top on mobile screens */
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
