:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --accent-color: #FF4081;
    --background-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #757575;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --result-bg: #e3f2fd;
    --divider-color: #f0f0f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

    /* Result box colors (light default) */
    --success-bg: #e8f5e9;
    --success-border: #c8e6c9;
    --success-text: #2e7d32;
    --error-bg: #ffebee;
    --error-border: #ffcdd2;
    --error-text: #c62828;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #121212;
        --card-bg: #1e1e1e;
        --text-color: #e0e0e0;
        --text-secondary: #b0b0b0;
        --input-bg: #2c2c2c;
        --input-border: #444;
        --result-bg: #1e3a5f;
        /* Darker blue for result */
        --divider-color: #333;
        --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);

        /* Adjust primary logic if needed, but blue usually works on dark too */
        --primary-dark: #64b5f6;
        /* Lighter blue for text on dark */

        /* Result box colors (dark) */
        --success-bg: #1b3320;
        --success-border: #2e7d32;
        --success-text: #a5d6a7;
        --error-bg: #3e1b1b;
        --error-border: #c62828;
        --error-text: #ef9a9a;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--background-color);
    padding: 16px;
}

header {
    padding: 16px 0;
    margin-bottom: 16px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    /* Add a little breathing room if needed */
}

header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

#clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

#clear-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--error-text);
    /* Make it red on hover to indicate destructive action */
}

#clear-btn:active {
    background-color: rgba(0, 0, 0, 0.1);
}

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--divider-color);
    padding-bottom: 8px;
}

.input-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input,
select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 1.1rem;
    transition: border-color 0.3s;
    background: var(--input-bg);
    color: var(--text-color);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Currency Converter Specifics */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}

#swap-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
    transition: transform 0.2s;
    flex-shrink: 0;
}

#swap-btn:active {
    transform: scale(0.95);
}

.toggle-container span {
    font-weight: bold;
    font-size: 1.2rem;
    min-width: 40px;
    text-align: center;
}

#currency-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

#currency-select {
    width: auto;
    min-width: 80px;
    padding: 8px 12px;
    font-weight: bold;
    cursor: pointer;
}

.toggle-container.swapped {
    flex-direction: row-reverse;
}

.result-display {
    text-align: center;
    background: var(--result-bg);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 8px;
}

#converted-amount {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

#currency-code {
    font-size: 1rem;
    color: var(--primary-color);
    margin-left: 4px;
}

.rate-info {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Change Calculator Specifics */
.input-with-select {
    display: flex;
    gap: 8px;
}

.input-with-select input {
    flex: 2;
}

.input-with-select select {
    flex: 1;
}

/* .sub-input span removed as we now use selects */

.payment-inputs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    /* Handle small screens */
}

.sub-input {
    flex: 1;
    min-width: 140px;
    /* Prevent crushing on mobile */
}

/* Ensure consistent height for adjacent elements */
.input-with-select input,
.input-with-select select {
    height: 46px;
    /* Explicit height to match */
    padding: 8px 12px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
    transition: background-color 0.2s;
}

.primary-btn:active {
    background-color: var(--primary-dark);
}

.result-box {
    margin-top: 20px;
    padding: 16px;
    background-color: var(--result-bg);
    /* Default fallback */
    border-radius: 8px;
    text-align: center;
    border: 1px solid transparent;
}

.result-box.hidden {
    display: none;
}

.result-box.success-state {
    background-color: var(--success-bg);
    border-color: var(--success-border);
}

.result-box.success-state h3,
.result-box.success-state .change-amount {
    color: var(--success-text);
}

.result-box.error-state {
    background-color: var(--error-bg);
    border-color: var(--error-border);
}

.result-box.error-state h3,
.result-box.error-state .change-amount {
    color: var(--error-text);
}

.result-box h3 {
    font-size: 1rem;
    /* Color handled by state class */
    margin-bottom: 8px;
}

.change-amount {
    font-size: 1.8rem;
    font-weight: bold;
    /* Color handled by state class */
}

.change-details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 24px;
    padding-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

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