/* Base CSS Variables for Light / Dark Mode */
:root {
    --bg-color: #f3f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-focus: #3b82f6;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --secondary-btn: #f1f5f9;
    --secondary-btn-hover: #e2e8f0;
    --secondary-btn-text: #475569;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Result Box Gradients */
    --primary-result-bg: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    --primary-result-text: #ffffff;
    --secondary-result-bg: #f8fafc;
    --secondary-result-text: #334155;
    --secondary-result-border: #e2e8f0;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --input-bg: #0f172a;
    --input-border: #334155;
    --input-focus: #3b82f6;
    --accent-color: #6366f1;
    --accent-hover: #818cf8;
    --secondary-btn: #334155;
    --secondary-btn-hover: #475569;
    --secondary-btn-text: #cbd5e1;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    
    --secondary-result-bg: #0f172a;
    --secondary-result-text: #f8fafc;
    --secondary-result-border: #334155;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 1.5rem;
}

/* Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--card-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

.theme-toggle:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Main Container & Card */
.calculator-container {
    width: 100%;
    max-width: 480px;
}

.calculator-card {
    background-color: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
}

/* Navigation */
.app-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    background-color: var(--card-bg);
    padding: 0.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
    border-radius: 12px;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.nav-link:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--accent-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Header */
.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.header-icon {
    color: var(--accent-color);
}

.card-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Forms & Inputs */
#calculatorForm {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.currency-symbol, .percent-symbol {
    position: absolute;
    color: var(--text-secondary);
    font-weight: 500;
    pointer-events: none;
}

.currency-symbol {
    left: 1rem;
}

.percent-symbol {
    right: 1rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: var(--shadow-sm);
    appearance: none;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#costPrice {
    padding-left: 2rem;
}

#desiredProfit, #platformFee {
    padding-right: 2.25rem;
}

input[type="number"]:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="number"].invalid {
    border-color: var(--error-color);
}

input[type="number"].invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.error-message {
    color: var(--error-color);
    font-size: 0.75rem;
    display: none;
    margin-top: -0.25rem;
    animation: fadeIn 0.2s ease;
}

/* Buttons */
.action-buttons {
    display: flex;
    justify-content: flex-end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

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

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

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    width: 100%;
    margin-top: 1rem;
    padding: 0.875rem;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--text-secondary);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.result-box {
    padding: 1.25rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: transform 0.2s ease;
}

.primary-result {
    background: var(--primary-result-bg);
    color: var(--primary-result-text);
    box-shadow: var(--shadow-md);
}

.primary-result .result-label {
    opacity: 0.9;
}

.secondary-result {
    background-color: var(--secondary-result-bg);
    border: 1px solid var(--secondary-result-border);
    color: var(--secondary-result-text);
}

.result-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.result-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    word-break: break-all;
}

.primary-result .result-value {
    font-size: 2rem;
}

.currency {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Toast */
.toast {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--text-primary);
    color: var(--bg-color);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

/* Responsive */
@media (max-width: 480px) {
    .calculator-card {
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .result-value {
        font-size: 1.5rem;
    }
    
    .primary-result .result-value {
        font-size: 1.75rem;
    }
    
    .theme-toggle {
        top: 1rem;
        right: 1rem;
        width: 36px;
        height: 36px;
    }

    .nav-link {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
}
