/* ========================================
   PAYMENT CFO - DESIGN SYSTEM
   Premium functionality with PayPal branding
   ======================================== */

/* --- 1. Design System & CSS Variables --- */
:root {
    /* PayPal Brand Colors */
    --brand-50: #f0f9ff;
    --brand-100: #e0f2fe;
    --brand-500: #0070ba; /* PayPal Blue */
    --brand-600: #003087; /* Darker Blue */
    --brand-900: #0c4a6e;
    
    /* Base Palette */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    /* Dark Theme Colors */
    --dark-bg: #0f172a; /* Slate 900 */
    --dark-card: #1e293b; /* Slate 800 */
    --dark-border: #334155;
    --dark-input: #0f172a;
    
    /* Semantic Colors */
    --color-blue: #3b82f6;
    --color-emerald: #10b981;
    --color-red: #ef4444;
    --color-orange: #f97316;
    
    /* Spacing & Radius */
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Support */
.dark {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

/* --- 2. Global Resets --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    transition: var(--transition-slow);
}

/* --- 3. Navigation Bar --- */
nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.dark nav {
    background: rgba(15, 23, 42, 0.9);
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--brand-500);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

.logo-text {
    font-family: 'Space Grotesk', sans-serif; /* Keep consistent with GigCalc branding if possible, else Oswald */
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    color: var(--text-main);
}

.logo-accent {
    color: var(--brand-500);
}

/* --- Theme Toggle --- */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--brand-500);
    background: var(--brand-50);
}

.dark .theme-toggle {
    background: var(--dark-border);
}

.dark .theme-toggle:hover {
    color: var(--brand-500);
    background: rgba(0, 112, 186, 0.2);
}

/* --- 4. Main Layout --- */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    main {
        grid-template-columns: 5fr 7fr;
    }
}

/* --- 5. Glass Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.dark .card {
    background: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    backdrop-filter: blur(12px);
}

.card-accent {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--brand-500);
}

/* --- 6. Mode Switcher (Receive / Ask) --- */
.mode-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.mode-btn {
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.875rem;
    border-radius: calc(var(--radius-xl) - 0.25rem);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mode-btn:hover {
    color: var(--text-main);
    background: var(--bg-input);
}

.mode-btn.active {
    background: var(--brand-500);
    color: white;
    box-shadow: var(--shadow-md);
}

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

.dark .mode-btn:hover {
    background: var(--dark-border);
}

/* --- 7. Form Elements --- */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.input-wrapper {
    position: relative;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--brand-500);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(0, 112, 186, 0.1);
}

.dark input[type="number"],
.dark select {
    background: var(--dark-input);
    border-color: var(--dark-border);
}

.dark input[type="number"]:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(0, 112, 186, 0.2);
}

/* --- Custom Select Dropdown --- */
.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    font-family: inherit;
}

.custom-select-trigger:hover {
    border-color: var(--brand-500);
}

.custom-select-trigger:focus {
    border-color: var(--brand-500);
    background: var(--bg-card);
}

.dark .custom-select-trigger {
    background: var(--dark-input);
    border-color: var(--dark-border);
}

.dark .custom-select-trigger:focus {
    border-color: var(--brand-500);
}

.custom-select-arrow {
    font-size: 0.625rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    display: none;
    position: fixed; /* Fixed to avoid overflow issues in cards */
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    overflow-y: auto;
    max-height: 250px;
    animation: selectSlideDown 0.2s ease-out;
}

/* Custom Scrollbar */
.custom-select-options::-webkit-scrollbar {
    width: 4px;
}
.custom-select-options::-webkit-scrollbar-track {
    background: var(--bg-input);
}
.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.dark .custom-select-options::-webkit-scrollbar-track {
    background: var(--dark-input);
}
.dark .custom-select-options::-webkit-scrollbar-thumb {
    background: var(--dark-border);
}

.custom-select-options.open {
    display: block;
}

.dark .custom-select-options {
    background: var(--dark-card);
    border-color: var(--dark-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

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

.custom-select-option {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.custom-select-option:hover {
    background: var(--bg-input);
    border-left-color: var(--brand-500);
    color: var(--brand-500);
}

.custom-select-option.selected {
    background: var(--brand-50);
    color: var(--brand-600);
    font-weight: 700;
    border-left-color: var(--brand-500);
}

.dark .custom-select-option:hover {
    background: var(--dark-border);
    color: var(--brand-500);
}

.dark .custom-select-option.selected {
    background: rgba(0, 112, 186, 0.1); /* Brand blue tint */
    color: var(--brand-500);
}

/* Remove Number Spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    appearance: textfield;
}

/* --- 8. Platform Selector (Specific to PayPal/Stripe tool) --- */
.platform-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.platform-btn {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.platform-btn:hover {
    border-color: var(--brand-500);
    color: var(--text-main);
    transform: translateY(-2px);
}

.platform-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s;
}

.platform-btn.active {
    background: var(--brand-500);
    color: white;
    border-color: var(--brand-500);
    box-shadow: var(--shadow-md);
    transform: scale(1);
    animation: buttonPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes buttonPop {
    0% { transform: scale(0.95); }
    40% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.dark .platform-btn {
    background: var(--dark-input);
    border-color: var(--dark-border);
}

.dark .platform-btn:hover {
    border-color: var(--brand-500);
    color: white;
}

/* --- 9. Toggle Switches --- */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border-color);
    transition: var(--transition);
    border-radius: 10px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--brand-500);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}
.dark .toggle-slider { background: var(--dark-border); }
.dark .toggle-slider::before { background: #cbd5e1; }

/* --- 10. Hero Result Card --- */
.hero-card {
    background: linear-gradient(135deg, #021B79 0%, #0570b9 100%); /* PayPal Gradient */
    border-radius: var(--radius-xl);
    padding: 2rem;
    color: white;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.hero-decoration {
    position: absolute;
    top: -80px;
    right: -80px;
    width: 256px;
    height: 256px;
    background: #009cde;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    transition: var(--transition-slow);
}

.hero-card:hover .hero-decoration {
    opacity: 0.5;
}

.hero-glow {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, #ffffff, transparent);
    opacity: 0.3;
}

.hero-label {
    color: #e0f2fe;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.hero-amount {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    margin-bottom: 2rem;
}

.hero-currency {
    font-size: 2rem;
    opacity: 0.8;
}

.hero-value {
    font-family: 'Oswald', 'Inter', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.025em;
}

@media (min-width: 768px) {
    .hero-value {
        font-size: 5rem;
    }
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
    margin-top: 2rem;
}

.hero-stat-label {
    font-size: 0.75rem;
    color: #bae6fd;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.hero-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.hero-stat-value.red {
    color: #fca5a5; /* Light red for fees */
}

/* --- 11. Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Breakdown List --- */
.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.breakdown-item:last-child { border-bottom: none; }

.item-label { color: var(--text-muted); font-size: 0.9rem; }
.item-value { font-weight: 600; font-size: 1rem; }
.text-red { color: var(--color-red); }

/* --- Copy Button --- */
.copy-btn {
    width: 100%;
    margin-top: 1rem;
    background: var(--text-main);
    color: var(--bg-body);
    border: none;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dark .copy-btn {
    background: white;
    color: black;
}

/* --- FX Warning --- */
.fx-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #d97706;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.dark .fx-warning { color: #fbbf24; }
.hidden { display: none !important; }

/* Large Input for Amount */
.large-input input {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.5rem 0.5rem 0.5rem 3rem; /* Space for symbol (increased for C$, A$, etc.) */
}
.large-input input::placeholder {
    font-size: 1rem;
    opacity: 0.6;
}
.large-input span.currency-symbol {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: var(--text-muted);
}

/* --- Added for JS Compatibility --- */
.platform-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

.platform-btn:hover .platform-dot {
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.6); /* Glow effect */
    transform: scale(1.1); /* Slight Zoom */
}

.platform-btn.active .platform-dot {
    border-radius: 0;
    background-color: #FFD700 !important; /* Gold Star */
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    width: 18px; /* Slightly larger */
    height: 18px;
    box-shadow: none;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
    animation: starPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes starPop {
    0% { transform: scale(0.5) rotate(-180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.fee-viz-bar {
    display: flex;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
}

.bar-segment { 
    height: 100%; 
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); 
}

.bg-net { background-color: var(--color-emerald); }
.bg-platform { background-color: var(--brand-500); }
.bg-conv { background-color: var(--color-orange); }

/* --- Table Styles --- */
table {
    width: 100%;
    border-collapse: collapse;
}

td, th {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

td {
    font-size: 0.9rem;
    color: var(--text-main);
}

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

.text-right { text-align: right; }
.text-strong { font-weight: 700; color: var(--text-main); }
.dark .text-strong { color: white; }

.best-badge {
    display: inline-block;
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 99px;
    margin-left: 0.5rem;
    text-transform: uppercase;
}
