/* ========================================
   EV Calculator V2 - Spreadsheet Style
   ======================================== */

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

:root {
    --primary: #217346;
    --primary-light: #e8f5e9;
    --header-bg: #1e4d2b;
    --cell-border: #c8c8c8;
    --cell-bg: #ffffff;
    --cell-alt: #f8f9fa;
    --label-bg: #f0f0f0;
    --petrol-bg: #fff8e1;
    --petrol-border: #ffca28;
    --ev-bg: #e3f2fd;
    --ev-border: #42a5f5;
    --positive: #2e7d32;
    --positive-bg: #c8e6c9;
    --negative: #c62828;
    --negative-bg: #ffcdd2;
    --text-primary: #212121;
    --text-secondary: #616161;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #e0e0e0;
    color: var(--text-primary);
    line-height: 1.4;
    min-height: 100vh;
}

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

/* ========================================
   Header
   ======================================== */
.header {
    background: var(--header-bg);
    color: white;
    padding: 15px 20px;
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.header .subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-left: 15px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-save,
.btn-clear {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-save {
    background: #4caf50;
    color: white;
}

.btn-save:hover {
    background: #43a047;
}

.btn-clear {
    background: #ff5722;
    color: white;
}

.btn-clear:hover {
    background: #e64a19;
}

/* ========================================
   Info Bar
   ======================================== */
.info-bar {
    background: #e3f2fd;
    padding: 10px 15px;
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    border-left: 4px solid #2196f3;
    border-bottom: 1px solid #c8c8c8;
}

.info-item {
    color: #1565c0;
}

/* ========================================
   Spreadsheet Container
   ======================================== */
.spreadsheet-container {
    background: var(--cell-bg);
    border: 1px solid var(--cell-border);
    border-radius: 0 0 4px 4px;
    box-shadow: var(--shadow);
}

/* ========================================
   Sheet Sections
   ======================================== */
.sheet-section {
    border-bottom: 2px solid var(--cell-border);
}

.sheet-section:last-child {
    border-bottom: none;
}

.sheet-header {
    background: var(--label-bg);
    padding: 8px 12px;
    border-bottom: 1px solid var(--cell-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sheet-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Spreadsheet Table
   ======================================== */
.spreadsheet {
    width: 100%;
    border-collapse: collapse;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
}

.spreadsheet th,
.spreadsheet td {
    border: 1px solid var(--cell-border);
    padding: 0;
    text-align: left;
    height: 36px;
    min-width: 120px;
}

.spreadsheet th {
    background: var(--label-bg);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 8px 10px;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Column Styles */
.col-label {
    min-width: 200px;
    background: var(--label-bg) !important;
}

.col-petrol {
    background: var(--petrol-bg) !important;
    border-left: 2px solid var(--petrol-border) !important;
}

.col-ev {
    background: var(--ev-bg) !important;
    border-left: 2px solid var(--ev-border) !important;
}

.col-add {
    background: var(--label-bg) !important;
    min-width: 100px;
    text-align: center;
}

/* Cell Styles */
.label-cell {
    background: var(--label-bg);
    padding: 0 10px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.petrol-cell {
    background: var(--petrol-bg);
}

.ev-cell {
    background: var(--ev-bg);
}

.readonly-cell {
    color: #999;
    text-align: center;
    font-style: italic;
}

.value-cell {
    min-width: 100px;
}

/* ========================================
   Input Cells
   ======================================== */
.cell-input {
    width: 100%;
    height: 100%;
    padding: 6px 10px;
    border: none;
    background: transparent;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    -moz-appearance: textfield;
}

.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Editable cells - WHITE background */
.cell-input.editable {
    background: #ffffff !important;
    border: 1px solid #bdbdbd;
    border-radius: 3px;
    margin: 2px;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
}

.cell-input.editable:hover {
    border-color: #2196f3;
}

.cell-input.editable:focus {
    background: #ffffff !important;
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.25);
}

.cell-input[readonly] {
    color: #666;
    background: transparent !important;
    border: none;
}

/* Settings Table */
.settings-table {
    margin: 0;
}

.settings-table td {
    min-width: 150px;
}

.settings-table .label-cell {
    width: 200px;
}

.settings-table .value-cell {
    width: 120px;
    background: #f5f5f5;
}

/* ========================================
   Help Icon - Blue Button Style
   ======================================== */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #2196f3;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
    text-decoration: none;
    border: none;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.help-icon:hover {
    background: #1565c0;
    transform: scale(1.1);
}

.help-icon:active {
    transform: scale(0.95);
}

/* ========================================
   Add EV Button
   ======================================== */
.btn-add-ev {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.btn-add-ev:hover {
    background: var(--header-bg);
}

/* Remove EV Button */
.btn-remove-ev {
    background: #ff5722;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    cursor: pointer;
    margin-left: 5px;
}

.btn-remove-ev:hover {
    background: #e64a19;
}

/* ========================================
   Results Table
   ======================================== */
.results-table .result-ev-col {
    min-width: 150px;
}

.result-cell {
    padding: 6px 10px !important;
    font-family: 'IBM Plex Mono', monospace;
}

.result-cell.positive {
    background: var(--positive-bg) !important;
    color: var(--positive);
    font-weight: 600;
}

.result-cell.negative {
    background: var(--negative-bg) !important;
    color: var(--negative);
    font-weight: 600;
}

.result-cell.highlight {
    font-weight: 700;
    font-size: 1rem;
}

.decision-row td {
    font-weight: 700;
    font-size: 0.95rem;
}

/* ========================================
   Summary Rows
   ======================================== */
.summary-row {
    background: #f5f5f5;
}

.summary-row .summary-label {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.summary-row .summary-cell {
    padding: 8px 12px !important;
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
}

.verdict-cell.positive {
    background: var(--positive-bg) !important;
    color: var(--positive);
}

.verdict-cell.negative {
    background: var(--negative-bg) !important;
    color: var(--negative);
}

.savings-value.positive {
    background: var(--positive-bg) !important;
    color: var(--positive);
}

.savings-value.negative {
    background: var(--negative-bg) !important;
    color: var(--negative);
}

.separator-row .separator-cell {
    background: #e0e0e0 !important;
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 5px 10px !important;
    height: auto !important;
}

.section-header {
    background: #e0e0e0 !important;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* ========================================
   Breakdown Section
   ======================================== */
.btn-toggle {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--cell-border);
    border-radius: 3px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}

.btn-toggle:hover {
    background: var(--cell-border);
}

.breakdown-container {
    padding: 10px;
    background: var(--cell-alt);
    max-height: 400px;
    overflow: auto;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 15px;
}

.breakdown-table th,
.breakdown-table td {
    border: 1px solid var(--cell-border);
    padding: 6px 10px;
    text-align: right;
}

.breakdown-table th {
    background: var(--label-bg);
    font-weight: 600;
    text-align: center;
}

.breakdown-table th:first-child,
.breakdown-table td:first-child {
    text-align: left;
}

.breakdown-table tr:nth-child(even) {
    background: var(--cell-alt);
}

.breakdown-table .battery-row {
    background: #fff3e0 !important;
}

.breakdown-table .total-row {
    background: var(--label-bg);
    font-weight: 700;
}

.breakdown-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin: 15px 0 8px 0;
    color: var(--text-secondary);
}

/* ========================================
   Footer
   ======================================== */
.footer {
    text-align: center;
    padding: 15px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.footer p {
    margin-bottom: 3px;
}

/* ========================================
   Help Modal
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 25px 30px;
    border-radius: 12px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalSlide 0.2s ease;
}

@keyframes modalSlide {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    margin-bottom: 12px;
    color: #1e4d2b;
    font-size: 1.2rem;
}

.modal-content p {
    color: #555;
    line-height: 1.7;
    font-size: 0.95rem;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    padding: 5px;
}

.modal-close:hover {
    color: #333;
}

/* ========================================
   Save Notification
   ======================================== */
.save-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--positive);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
    z-index: 1000;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

    .header {
        flex-direction: column;
        text-align: center;
    }

    .header .subtitle {
        margin-left: 0;
    }

    .info-bar {
        flex-direction: column;
        gap: 8px;
    }

    .spreadsheet-container {
        overflow-x: auto;
    }

    .spreadsheet {
        min-width: 600px;
    }

    .settings-table {
        min-width: 500px;
    }
}