/* CSS Variables for theming */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8888a0;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 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);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16162a;
    --text-primary: #f0f0f5;
    --text-secondary: #b0b0c0;
    --text-muted: #6a6a80;
    --border-color: #2a2a40;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 20px;
    position: relative;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

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

.theme-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Input Section */
.input-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* Form Groups */
.form-group {
    margin-bottom: 18px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.input-with-unit .currency {
    font-weight: 500;
    color: var(--text-muted);
}

.input-with-unit .unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.input-with-unit select {
    width: auto;
    min-width: 80px;
}

.time-inputs {
    display: flex;
    gap: 12px;
}

.time-inputs .input-with-unit {
    flex: 1;
}

.hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-md);
}

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

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

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-card);
}

/* Results Section */
.output-section {
    margin-top: 30px;
}

.results-card {
    margin-bottom: 20px;
}

.results-card.highlight {
    border: 2px solid var(--accent-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
}

/* Cost Breakdown */
.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-item.total {
    margin-top: 10px;
    padding-top: 16px;
    border-top: 2px solid var(--accent-primary);
    border-bottom: none;
}

.cost-item.total .cost-label,
.cost-item.total .cost-value {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent-primary);
}

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

.cost-value {
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Pricing Display */
.pricing-display {
    text-align: center;
}

.main-price {
    padding: 30px 0;
}

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

.price-value {
    font-size: 3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.price-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item span:first-child {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-item span:last-child {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.detail-item .profit {
    color: var(--success);
}

/* Bulk Pricing Table */
.bulk-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.bulk-pricing-table {
    overflow-x: auto;
}

.bulk-header,
.bulk-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 12px 16px;
    text-align: center;
}

.bulk-header {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bulk-row {
    border-bottom: 1px solid var(--border-color);
}

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

.bulk-row:hover {
    background: var(--bg-secondary);
}

.bulk-price {
    font-weight: 600;
    color: var(--accent-primary);
}

.bulk-discount {
    color: var(--warning);
}

.bulk-profit {
    color: var(--success);
    font-weight: 500;
}

/* Profit Analysis */
.profit-scenarios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.scenario {
    text-align: center;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

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

.scenario h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.scenario-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.scenario small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Export Section */
.export-section {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 30px;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: var(--text-primary);
}

/* Preset List */
.preset-list {
    max-height: 300px;
    overflow-y: auto;
}

.preset-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-item:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
}

.preset-item .preset-name {
    font-weight: 500;
}

.preset-item .preset-delete {
    color: var(--danger);
    cursor: pointer;
    padding: 4px 8px;
}

.preset-item .preset-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius-sm);
}

.no-presets {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

footer .disclaimer {
    font-size: 0.85rem;
    margin-top: 8px;
    opacity: 0.8;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-card {
    animation: fadeIn 0.3s ease forwards;
}

.results-card:nth-child(2) { animation-delay: 0.1s; }
.results-card:nth-child(3) { animation-delay: 0.2s; }
.results-card:nth-child(4) { animation-delay: 0.3s; }

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .theme-btn {
        position: static;
        margin-top: 15px;
    }

    header {
        padding: 20px;
    }

    .input-section {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }

    .time-inputs {
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .price-value {
        font-size: 2.2rem;
    }

    .price-details {
        grid-template-columns: 1fr;
    }

    .bulk-header,
    .bulk-row {
        font-size: 0.85rem;
        padding: 10px;
    }

    .profit-scenarios {
        grid-template-columns: repeat(2, 1fr);
    }

    .export-section {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .profit-scenarios {
        grid-template-columns: 1fr;
    }

    .scenario-value {
        font-size: 1.2rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Print styles */
@media print {
    .action-buttons,
    .theme-btn,
    .export-section,
    .input-section {
        display: none;
    }

    .output-section {
        display: block !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
