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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

/* Header styles */
header {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    color: #2c3e50;
    font-size: 2rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.country-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.country-selector label {
    font-weight: 600;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    min-width: 200px;
}

/* Tab styles */
.tab-container {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tab-header {
    display: flex;
    background-color: #000;
    overflow-x: auto;
}

.tab-button {
    padding: 15px 25px;
    border: none;
    background-color: #000;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-button:hover {
    background-color: #333;
}

.tab-button.active {
    background-color: #00008B;
    color: #FFFFE0;
}

.tab-button.profitability-tab {
    margin-left: auto;
    background-color: #000080;
}

.tab-button.profitability-tab.active {
    background-color: #00008B;
    color: #FFFFE0;
}

/* Tab content */
.tab-content {
    padding: 20px;
    min-height: 500px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Form styles */
.form-section {
    margin-bottom: 30px;
}

.form-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 400px 150px auto;
    gap: 15px;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #ecf0f1;
}

.form-row:hover {
    background-color: #f8f9fa;
}

.form-row label {
    font-weight: 500;
}

.form-row input[type="number"],
.form-row input[type="text"],
.form-row select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
}

.form-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.form-row .description {
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
}

/* Button styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

/* Results display */
.calculation-results {
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5;
}

#results-content {
    flex: 1;
    overflow-y: auto;
    max-height: 700px;
    background-color: white;
    border: 1px solid #ccc;
    margin: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: white;
}

.result-section {
    margin-bottom: 20px;
}

.result-header {
    padding: 8px 15px;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 14px;
    border-bottom: 2px solid #333;
    letter-spacing: 0.5px;
}

.result-row {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr;
    column-gap: 20px;
    padding: 6px 15px;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
    min-height: 30px;
    font-size: 13px;
}

.result-row span:nth-child(1) {
    font-weight: 500;
}

.result-row span:nth-child(2) {
    text-align: right;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    padding-right: 10px;
}

.result-row span:nth-child(3) {
    font-size: 11px;
    color: #666;
    font-style: italic;
}

/* Spreadsheet-style formatting */
.action-buttons {
    padding: 15px;
    background-color: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

/* Results summary cards */
.results-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.summary-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.summary-card h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card .summary-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.summary-card.profit {
    border-top: 4px solid #27ae60;
}

.summary-card.profit .summary-value {
    color: #27ae60;
}

.summary-card.income {
    border-top: 4px solid #3498db;
}

.summary-card.income .summary-value {
    color: #3498db;
}

.summary-card.costs {
    border-top: 4px solid #e74c3c;
}

.summary-card.costs .summary-value {
    color: #e74c3c;
}

.summary-card.expenses {
    border-top: 4px solid #f39c12;
}

.summary-card.expenses .summary-value {
    color: #f39c12;
}

/* Results details section */
.results-details {
    padding: 10px 0;
}

/* Main section headers (black background) */
.result-header[style*="background-color: rgb(0, 0, 0)"] {
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%) !important;
    color: #fff !important;
    font-size: 16px;
    padding: 12px 15px;
    margin-top: 15px;
    border-left: 5px solid #3498db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Sub-section headers (gray background) */
.result-header[style*="background-color: rgb(211, 211, 211)"] {
    background-color: #ecf0f1 !important;
    color: #2c3e50 !important;
    font-size: 13px;
    padding: 8px 15px;
    border-left: 3px solid #95a5a6;
    margin-top: 5px;
}

/* Total rows - Income (green) */
.result-row[style*="background-color: rgb(0, 100, 0)"] {
    background: linear-gradient(90deg, #27ae60 0%, #229954 100%) !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 15px;
    padding: 10px 15px;
    margin: 5px 0;
    box-shadow: 0 2px 4px rgba(39, 174, 96, 0.3);
}

/* Total rows - Expenses (red) */
.result-row[style*="background-color: rgb(139, 0, 0)"] {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%) !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 15px;
    padding: 10px 15px;
    margin: 5px 0;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

/* Total rows - Write-offs (dark gray) */
.result-row[style*="background-color: rgb(85, 85, 85)"] {
    background: linear-gradient(90deg, #7f8c8d 0%, #95a5a6 100%) !important;
    color: #fff !important;
    font-weight: 700;
    padding: 10px 15px;
    margin: 5px 0;
}

/* Regular data rows */
.result-row:not([style]) {
    transition: background-color 0.2s ease;
}

.result-row:not([style]):hover {
    background-color: #f8f9fa;
}

/* Alternating row colors for better readability */
.result-row:not([style]):nth-child(even) {
    background-color: #fafafa;
}

/* Special formatting for key metrics */
.result-row span:contains("Total Number of Orders"),
.result-row span:contains("Daily Sales per Establishment") {
    font-weight: 600;
    color: #2c3e50;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .form-row,
    .result-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .tab-button {
        padding: 10px 15px;
        font-size: 12px;
    }
}