@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    --bg-primary: #070913;
    --bg-secondary: #0d1024;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-card: rgba(255, 255, 255, 0.08);
    
    --color-primary: #8b5cf6;       /* Violet */
    --color-primary-glow: rgba(139, 92, 246, 0.35);
    --color-secondary: #06b6d4;     /* Cyan */
    --color-secondary-glow: rgba(6, 182, 212, 0.35);
    
    --color-accent: #f59e0b;        /* Gold/PromptPay Yellow */
    --color-promptpay: #002d63;     /* PromptPay Blue */
    --color-promptpay-light: #0056b3;
    
    --color-success: #10b981;       /* Emerald */
    --color-success-glow: rgba(16, 185, 129, 0.3);
    --color-error: #ef4444;         /* Rose */
    --color-error-glow: rgba(239, 68, 68, 0.3);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --font-sans: 'Outfit', 'Sarabun', sans-serif;
    
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Header Styles */
header {
    padding: 2rem 2rem 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--color-primary-glow);
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff 30%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--color-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Main Container Layout */
main {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 2rem 3rem 2rem;
    flex: 1;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
}

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

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

/* Left Panel - Control Form */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title svg {
    color: var(--color-secondary);
}

/* Tab Navigation */
.tab-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    border: 1px solid var(--border-card);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.65rem 0.25rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-btn svg,
.tab-btn * {
    pointer-events: none;
}

.tab-btn svg {
    width: 18px;
    height: 18px;
}

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

/* Input Fields */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-dim);
    transition: var(--transition-smooth);
    pointer-events: none;
}

.form-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    padding: 1rem 1rem 1rem 2.75rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 15px var(--color-primary-glow);
    background: rgba(0, 0, 0, 0.35);
}

.form-input:focus ~ .input-icon {
    color: var(--color-primary);
}

/* Validation status classes */
.form-input.is-valid {
    border-color: var(--color-success);
}
.form-input.is-valid:focus {
    box-shadow: 0 0 15px var(--color-success-glow);
}
.form-input.is-valid ~ .input-icon {
    color: var(--color-success);
}

.form-input.is-invalid {
    border-color: var(--color-error);
}
.form-input.is-invalid:focus {
    box-shadow: 0 0 15px var(--color-error-glow);
}
.form-input.is-invalid ~ .input-icon {
    color: var(--color-error);
}

.validation-msg {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}
.validation-msg.error {
    color: var(--color-error);
    display: block;
}

/* Presets & Amount Styling */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-card);
    color: var(--text-muted);
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

.preset-btn.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

/* Submit Actions */
.actions-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: white;
    box-shadow: 0 4px 20px var(--color-primary-glow);
}

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

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

.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    box-shadow: none;
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: none;
}

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

.btn.loading .spinner {
    display: block;
}
.btn.loading span {
    display: none;
}

/* Right Panel - Outputs & Preview */
.output-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* QR Code Card Design */
.qr-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    min-height: 380px;
}

.qr-box-container {
    position: relative;
    padding: 1.25rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.qr-box-container.glowing::after {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    z-index: -1;
    border-radius: calc(var(--radius-lg) + 2px);
    filter: blur(15px);
    opacity: 0.4;
    transition: var(--transition-smooth);
}

.qr-placeholder {
    width: 220px;
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-dim);
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    background: #fafafa;
}

.qr-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.qr-placeholder p {
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    max-width: 150px;
}

canvas#qr-canvas {
    width: 220px !important;
    height: 220px !important;
    display: none;
}

/* PromptPay Stamp Info on Card */
.promptpay-header {
    width: 100%;
    max-width: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--color-promptpay);
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    margin-bottom: 0.25rem;
    box-shadow: inset 0 1px 3px rgba(255,255,255,0.2);
}

.promptpay-header img {
    height: 24px;
    object-fit: contain;
}

.qr-details {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.qr-details .payee-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
}

.qr-details .pay-amount {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-secondary);
}

.qr-details .pay-id {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

.qr-actions-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
}

.qr-action-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card);
    color: var(--text-muted);
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.qr-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.15);
}

.qr-action-btn svg {
    width: 18px;
    height: 18px;
    color: var(--color-secondary);
}

/* Smartphone Simulator Card */
.simulator-card {
    background: #090a16;
    border: 2px solid #1a1e38;
    border-radius: 40px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Phone notch/top bar */
.simulator-notch {
    width: 110px;
    height: 20px;
    background: #1a1e38;
    border-radius: 0 0 15px 15px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.simulator-screen {
    background: #f1f5f9;
    border-radius: 28px;
    min-height: 420px;
    overflow: hidden;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-header {
    background: linear-gradient(135deg, var(--color-promptpay), var(--color-promptpay-light));
    color: white;
    padding: 1.5rem 1rem 1rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sim-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sim-header span {
    font-size: 0.7rem;
    opacity: 0.75;
}

.sim-body {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.sim-transfer-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.sim-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 0.5rem;
}

.sim-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sim-label {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
}

.sim-value {
    color: #0f172a;
    font-weight: 600;
}

.sim-value.payee {
    color: var(--color-promptpay-light);
}

.sim-amount-container {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.sim-amount-title {
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 0.15rem;
    font-weight: 500;
}

.sim-amount-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
}

.sim-amount-val span {
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    margin-left: 0.25rem;
}

.sim-btn {
    background: var(--color-success);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: auto;
    text-align: center;
    box-shadow: 0 4px 10px var(--color-success-glow);
    transition: var(--transition-smooth);
}

.sim-btn:hover {
    background: #059669;
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.4);
}

/* History Logs Container */
.history-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.history-card-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-card-header h3 svg {
    color: var(--color-primary);
}

.clear-history-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.clear-history-btn:hover {
    color: var(--color-error);
}

.history-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-card);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.history-table th, .history-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-card);
}

.history-table th {
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.01);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-phone { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-id { background: rgba(6, 182, 212, 0.15); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-corporate { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-wallet { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

.history-amount {
    font-weight: 600;
    color: var(--color-secondary);
}

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

.history-action-icon {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-card);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-smooth);
}

.history-action-icon:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.history-action-icon.delete:hover {
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.empty-history {
    padding: 2.5rem;
    text-align: center;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-history svg {
    width: 40px;
    height: 40px;
    opacity: 0.3;
}

/* Footer */
footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: auto;
    border-top: 1px solid var(--border-card);
    background: rgba(0, 0, 0, 0.1);
}

footer a {
    color: var(--color-secondary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Dynamic slider animation for simulator success */
.success-screen-animation {
    background: var(--color-success);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    animation: slideUp 0.4s ease-out forwards;
    padding: 2rem;
    text-align: center;
    gap: 1rem;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.success-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.success-screen-animation h4 {
    font-size: 1.2rem;
    font-weight: 600;
}

.success-screen-animation p {
    font-size: 0.8rem;
    opacity: 0.9;
}

.success-close-btn {
    background: white;
    color: var(--color-success);
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    transition: var(--transition-smooth);
}

.success-close-btn:hover {
    background: #f1f5f9;
}

/* ──────────────────────────────────────
   Corporate Logo Upload
────────────────────────────────────── */
.logo-upload-area {
    border: 2px dashed rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: rgba(16, 185, 129, 0.03);
    user-select: none;
}

.logo-upload-area:hover {
    border-color: var(--color-success);
    background: rgba(16, 185, 129, 0.07);
}

.logo-upload-area.drag-over {
    border-color: var(--color-success);
    background: rgba(16, 185, 129, 0.12);
    transform: scale(1.01);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.2);
}

.logo-preview-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(16, 185, 129, 0.07);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

.logo-preview-thumb {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
    padding: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.logo-clear-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--color-error);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.logo-clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-error);
}
