/* ========================================
   Modern Payment UI - Clean & Minimal
   ======================================== */

/* CSS Custom Properties - Design Tokens */
:root {
    /* Colors - Dark Mode (Default) */
    --bg-primary: #0f0f11;
    --bg-secondary: #1a1a1e;
    --bg-tertiary: #25252a;
    --bg-elevated: #2d2d33;

    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-secondary: #8b5cf6;
    --accent-success: #22c55e;
    --accent-error: #ef4444;
    --accent-warning: #f59e0b;

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f0f11;

    /* Border Colors */
    --border-default: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(99, 102, 241, 0.5);

    /* Spacing Scale (8px base) */
    --space-1: 0.25rem; /* 4px */
    --space-2: 0.5rem; /* 8px */
    --space-3: 0.75rem; /* 12px */
    --space-4: 1rem; /* 16px */
    --space-5: 1.25rem; /* 20px */
    --space-6: 1.5rem; /* 24px */
    --space-8: 2rem; /* 32px */
    --space-10: 2.5rem; /* 40px */
    --space-12: 3rem; /* 48px */

    /* Border Radius */
    --radius-sm: 0.375rem; /* 6px */
    --radius-md: 0.5rem; /* 8px */
    --radius-lg: 0.75rem; /* 12px */
    --radius-xl: 1rem; /* 16px */
    --radius-2xl: 1.5rem; /* 24px */

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md:
        0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg:
        0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    /* Typography */
    --font-sans:
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
        Arial, sans-serif;
    --font-mono:
        'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Z-Index Scale */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal-backdrop: 300;
    --z-modal: 400;
    --z-popover: 500;
    --z-tooltip: 600;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    background: var(--accent-primary);
    color: var(--text-inverse);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    z-index: 9999;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-4);
}

/* ========================================
   Typography
   ======================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.25rem;
}

p {
    color: var(--text-secondary);
}

/* ========================================
   Layout
   ======================================== */

.container {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: var(--space-6);
}

@media (max-width: 640px) {
    .container {
        padding: var(--space-4);
    }
}

/* Stack Layout */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.stack-lg {
    gap: var(--space-8);
}

/* ========================================
   Cards
   ======================================== */

.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition:
        border-color var(--transition-base),
        box-shadow var(--transition-base);
}

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

.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-default);
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-default);
}

/* Gradient Header for Summary Card */
.card-gradient {
    background: linear-gradient(
        135deg,
        var(--accent-primary),
        var(--accent-secondary)
    );
    color: white;
    border: none;
}

.card-gradient h2,
.card-gradient p {
    color: white;
}

.card-gradient .text-muted {
    color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    border-color: var(--accent-primary-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-secondary:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--border-default);
}

.btn-outline:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--accent-error);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: 0.875rem;
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

/* Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Payment Method Buttons - Sleek Design
   ======================================== */

.payment-method-btn {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-4) var(--space-5);
    background: linear-gradient(
        145deg,
        rgba(45, 45, 51, 0.6),
        rgba(37, 37, 42, 0.8)
    );
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
    backdrop-filter: blur(10px);
}

.payment-method-btn:hover {
    background: linear-gradient(
        145deg,
        rgba(55, 55, 63, 0.8),
        rgba(45, 45, 51, 1)
    );
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.payment-method-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

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

.payment-method-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Card Method - Sleek Purple */
.payment-method-card .payment-method-icon {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

/* Digital Wallet Methods - Dark */
.payment-method-wallet .payment-method-icon {
    background: linear-gradient(135deg, #1f1f24 0%, #2d2d33 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Pay Later Methods - Pink/Rose */
.payment-method-later .payment-method-icon {
    background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%);
}

/* Bank Transfer Methods - Cyan/Blue */
.payment-method-bank .payment-method-icon {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

.payment-method-info {
    flex: 1;
}

.payment-method-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
}

.payment-method-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.payment-method-arrow {
    color: var(--text-muted);
    transition: transform var(--transition-base);
    opacity: 0.6;
}

.payment-method-btn:hover .payment-method-arrow {
    transform: translateX(3px);
    color: var(--text-secondary);
    opacity: 1;
}

/* Disabled state for unavailable methods */
.payment-method-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-label-required::after {
    content: ' *';
    color: var(--accent-error);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: all var(--transition-base);
}

.form-input:hover {
    border-color: var(--border-hover);
}

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

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

.form-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-input-error {
    border-color: var(--accent-error) !important;
}

.form-input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.form-error-msg {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 0.875rem;
    color: var(--accent-error);
}

.form-hint {
    margin-top: var(--space-2);
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Input Groups */
.input-group {
    display: flex;
    gap: var(--space-3);
}

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

.input-group-prefix {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9375rem;
}

/* ========================================
   Alert Messages
   ======================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
}

.alert-success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.alert-content {
    flex: 1;
}

.alert-close {
    flex-shrink: 0;
    padding: var(--space-1);
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.alert-close:hover {
    opacity: 1;
}

/* ========================================
   Accordion / Dropdown
   ======================================== */

.accordion-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-4) var(--space-6);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.accordion-trigger:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
}

.accordion-trigger[aria-expanded='true'] {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.accordion-icon {
    transition: transform var(--transition-base);
}

.accordion-trigger[aria-expanded='true'] .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    padding: var(--space-6);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-top: none;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.accordion-content[hidden] {
    display: none;
}

/* ========================================
   Logs Section
   ======================================== */

.logs-container {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    height: 300px;
    overflow: hidden;
}

.logs-scroll {
    height: 100%;
    overflow-y: auto;
    padding: var(--space-4);
}

.log-entry {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry-success {
    color: var(--accent-success);
}

.log-entry-error {
    color: var(--accent-error);
}

.log-entry-info {
    color: #60a5fa;
}

.logs-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}

/* ========================================
   Modal
   ======================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform var(--transition-base);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-default);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    padding: var(--space-2);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
    max-height: 60vh;
    overflow-y: auto;
}

/* Bank List */
.bank-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.bank-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
}

.bank-item:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-hover);
}

.bank-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(
        135deg,
        var(--accent-primary),
        var(--accent-secondary)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: white;
}

.bank-info {
    flex: 1;
}

.bank-name {
    font-weight: 500;
    color: var(--text-primary);
}

.bank-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ========================================
   Status Badge
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 9999px;
}

.badge-pending {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* ========================================
   Utilities
   ======================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

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

.font-mono {
    font-family: var(--font-mono);
}

.flex {
    display: flex;
}

.flex-between {
    justify-content: space-between;
}

.flex-center {
    align-items: center;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-4 {
    gap: var(--space-4);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-2 {
    margin-bottom: var(--space-2);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   Animations
   ======================================== */

@media (prefers-reduced-motion: no-preference) {
    .fade-in {
        animation: fadeIn 0.3s ease;
    }

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

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

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .card-header,
    .card-body {
        padding: var(--space-4);
    }

    .input-group {
        flex-direction: column;
        gap: var(--space-3);
    }

    .payment-method-btn {
        padding: var(--space-4);
    }

    .payment-method-icon {
        width: 40px;
        height: 40px;
    }
}

/* Safe Area for Mobile Devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(var(--space-6), env(safe-area-inset-left));
        padding-right: max(var(--space-6), env(safe-area-inset-right));
        padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .logs-container,
    .accordion,
    .btn-secondary,
    .btn-ghost {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ccc;
        break-inside: avoid;
    }
}

/* ========================================
   SDK Field Overrides
   ======================================== */

#card-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

#card-details input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: all var(--transition-base);
}

#card-details input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

/* ========================================
   SDK Button Styling - Apple Pay & Google Pay
   ======================================== */

/* Ensure SDK buttons match other payment method buttons */
#apple-pay,
#google-pay {
    width: 100%;
}

#apple-pay > *,
#google-pay > * {
    width: 100% !important;
    height: 56px !important;
    min-height: 56px !important;
    border-radius: var(--radius-xl) !important;
}

/* Apple Pay button specific styling */
#apple-pay apple-pay-button {
    --apple-pay-button-width: 100% !important;
    --apple-pay-button-height: 56px !important;
    --apple-pay-button-border-radius: var(--radius-xl) !important;
    height: 56px !important;
    min-height: 56px !important;
}

/* Google Pay button container */
#google-pay .gpay-button {
    width: 100% !important;
    height: 56px !important;
    border-radius: var(--radius-xl) !important;
}

/* ========================================
   SVEA Payment Iframe (Vipps/MobilePay) Styling
   ======================================== */

/* Ensure SVEA iframes are properly centered */
#vipps-widget,
#mobilepay-widget {
    position: relative;
    width: 100%;
}

/* Fix for SVEA payment iframe positioning */
[id^='sb-svea-'] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(10px) !important;
}

[id^='sb-svea-'] > div {
    width: 90% !important;
    height: 90% !important;
    max-width: 600px !important;
    max-height: 800px !important;
    margin: auto !important;
}

[id^='sb-svea-'] iframe {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: var(--radius-xl) !important;
}
