:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-light: #ede9fe;
    --border: #e2e8f0;
    --success: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #a78bfa;
    --accent-hover: #8b5cf6;
    --accent-light: #1e1b4b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.calculator-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-with-currency {
    display: flex;
    gap: 0.5rem;
}

.input-with-currency select {
    width: 110px;
    flex-shrink: 0;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.rate-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.rate-selector select {
    flex: 1;
    min-width: 200px;
}

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

.custom-rate {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.custom-rate input {
    width: 80px;
    text-align: center;
}

.percent {
    color: var(--text-secondary);
    font-weight: 600;
}

.operation-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.toggle-btn {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.toggle-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

.toggle-btn .icon {
    font-size: 1.1rem;
}

.results-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.result-row:last-child {
    border-bottom: none;
}

.result-row .label {
    color: var(--text-secondary);
}

.result-row .value {
    font-size: 1.25rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.result-row.highlight .value {
    color: var(--accent);
}

.result-row.total {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 2px solid var(--border);
}

.result-row.total .label {
    font-weight: 600;
    color: var(--text-primary);
}

.result-row.total .value {
    font-size: 1.5rem;
    color: var(--success);
}

.copy-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.copy-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.copy-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.copy-btn.copied {
    background: var(--success);
}

.info-section {
    margin-top: 2rem;
}

.info-section h2 {
    font-size: 1.25rem;
    margin: 1.5rem 0 1rem;
    color: var(--text-primary);
}

.info-section p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.info-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.info-card p {
    font-size: 0.875rem;
}

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

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

.disclaimer {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.2s;
    z-index: 100;
}

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

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .calculator-card {
        padding: 1.5rem;
    }

    .rate-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .rate-selector select {
        min-width: auto;
    }

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

    .custom-rate {
        justify-content: center;
    }

    .operation-toggle {
        flex-direction: column;
    }
}
