@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans+Expanded:wght@400;700&display=swap');

:root {
    /* --- Color Palette based on Logo --- */
    --primary-color: #2980b9;  /* Blue from VOLT */
    --primary-light: #3498db;  /* Lighter blue for hover */
    --primary-dark: #1c638b;   /* Darker blue for active states */
    --accent-color: #f39c12;   /* Orange/Gold from RAY */
    --accent-darker: #e67e22;  /* Darker shade for hover */
    --accent-light: #f9c869;   /* Lighter shade for backgrounds */

    /* --- Neutrals --- */
    --light-grey: #f5f7fa;     /* Lighter background grey */
    --medium-grey: #dce1e6;    /* Borders */
    --dark-grey: #2c3e50;      /* Body text */
    --white: #ffffff;
    --off-white: #fbfcfe;      /* Subtle off-white for backgrounds */

    /* --- Semantic Colors --- */
    --profit-color: #27ae60;   /* Green for profit/benefit */
    --loss-color: #e74c3c;     /* Red for loss/cost */

    /* --- Utility --- */
    --danger-bg: #f8d7da;
    --danger-border: #f5c6cb;
    --danger-text: #721c24;    /* Keep distinct from loss color */
    
    /* --- Shadows --- */
    --card-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    --input-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    --button-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    
    /* --- Transitions --- */
    --fast-transition: 0.2s ease;
    --medium-transition: 0.3s ease;
}

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nunito Sans Expanded', sans-serif;
    line-height: 1.6;
    background: linear-gradient(to bottom right, var(--light-grey), var(--off-white));
    color: var(--dark-grey);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Base font for body text */
body {
    font-family: 'Nunito Sans';
}

/* Headings use League Spartan */
h1, h2, h3, h4, h5, h6 {
    font-family: 'League Spartan';
}

/* All other elements inherit from body */
* {
    font-family: inherit;
}

/* --- Layout --- */
.calculator-wrapper {
    width: 100%;
    max-width: 1400px; /* Max width for larger screens */
    margin: 20px auto;
    background-color: var(--white);
    box-shadow: var(--card-shadow);
    border-radius: 12px;
    overflow: hidden; /* Ensure child elements respect border-radius */
    flex: 1;
    display: flex;
}

#sidebar {
    background-color: var(--white);
    padding: 30px 35px;
    border-right: 1px solid var(--medium-grey);
    box-shadow: inset -5px 0 10px -5px rgba(0, 0, 0, 0.05);
    width: 380px;
    flex-shrink: 0;
    overflow-y: auto;
    background-image: linear-gradient(to bottom, #ffffff, #f9fbff);
}

#main-content {
    padding: 35px 40px;
    background: linear-gradient(to bottom right, var(--off-white), var(--white));
    flex-grow: 1;
}

/* --- Sidebar Content --- */
.sidebar-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--medium-grey);
    position: relative;
}

.sidebar-header:after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 80px;
    height: 3px;
    background-color: var(--accent-color);
}

.sidebar-header h1 {
    color: var(--primary-color);
    font-size: 1.6em;
    margin-bottom: 5px;
    font-weight: 700;
    font-family: 'League Spartan';
}

.sidebar-header p {
    color: var(--dark-grey);
    font-size: 0.95em;
    margin-bottom: 0;
    opacity: 0.9;
    font-family: 'League Spartan';
}

.sidebar-logo {
    display: block;
    max-width: 240px;
    height: auto;
    margin-bottom: 0;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1));
}

.company-name {
    font-size: 1.1em;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0;
}

.input-form {
    padding-right: 5px;
}

.input-form h2 {
    font-size: 1.3em;
    color: var(--primary-color);
    margin-bottom: 25px;
    margin-top: 35px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    text-align: left;
    position: relative;
    font-family: 'League Spartan';
}

.input-form h2:first-of-type {
    margin-top: 0;
}

.input-group {
    margin-bottom: 22px;
    position: relative;
}

.input-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-grey);
    font-size: 1.05em;
}

.input-form input[type="number"] {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 0;
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    transition: all var(--fast-transition);
    font-size: 1.05em;
    background-color: var(--white);
    box-shadow: var(--input-shadow);
}

.input-form input[type="number"]:focus {
    border-color: var(--accent-color);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.25);
}

.input-form select {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 0;
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    transition: all var(--fast-transition);
    font-size: 1.05em;
    background-color: var(--white);
    box-shadow: var(--input-shadow);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232c3e50' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

.input-form select:focus {
    border-color: var(--accent-color);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.25);
}

.input-form small {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--dark-grey);
    opacity: 0.7;
}

.input-form button {
    display: block;
    width: 100%;
    padding: 14px 15px;
    background: linear-gradient(to right, var(--accent-color), var(--accent-darker));
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--medium-transition);
    margin-top: 35px;
    box-shadow: var(--button-shadow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-form button:hover {
    background: linear-gradient(to right, var(--accent-darker), var(--accent-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.input-form button:active {
    transform: translateY(0);
    box-shadow: var(--button-shadow);
}

.input-form button.calculate-btn {
    background-image: linear-gradient(to right, var(--accent-light), var(--accent-color));
    background-size: 200% auto;
    background-position: left center;
    transition: background-position 0.5s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.input-form button.calculate-btn:hover {
    background-position: right center;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.input-form button.calculate-btn:active {
    transform: translateY(0) scale(1);
    box-shadow: var(--button-shadow);
}

.error-message {
    color: var(--danger-text);
    font-weight: 500;
    font-size: 0.9em;
    margin-top: 15px;
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    padding: 12px 15px;
    border-radius: 8px;
    text-align: left;
    box-shadow: var(--input-shadow);
}

/* --- Main Content Styling --- */
#main-content h2 {
    color: var(--primary-color);
    font-size: 1.8em;
    margin-bottom: 30px;
    text-align: center;
    position: relative;
    padding-bottom: 12px;
    font-family: 'League Spartan';
}

#main-content h2:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 3px;
    background-color: var(--accent-color);
}

#main-content h3 {
    color: var(--primary-color);
    font-size: 1.4em;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
    font-family: 'League Spartan';
}

.results-section {
    margin-top: 0;
    padding: 25px;
    border-radius: 10px;
    background-color: var(--white);
    box-shadow: var(--card-shadow);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 35px;
    border: 1px solid var(--medium-grey);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.data-table th, .data-table td {
    padding: 12px 18px;
    text-align: left;
    border-bottom: 1px solid var(--medium-grey);
}

.data-table th {
    background: linear-gradient(to bottom right, rgba(41, 128, 185, 0.2), rgba(41, 128, 185, 0.05));
    font-weight: 600;
    font-size: 1em;
    color: var(--primary-dark);
    white-space: nowrap;
    border-bottom-width: 2px;
    border-bottom-color: var(--primary-light);
}

.data-table td {
    font-size: 1em;
    color: var(--dark-grey);
    vertical-align: middle;
    transition: background-color var(--fast-transition);
}

.data-table tr:hover td {
    background-color: rgba(243, 156, 18, 0.05);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table td:nth-child(n+2) {
    text-align: right;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 0.95em;
    font-weight: 500;
}

.data-table .metric-col {
    text-align: left;
    font-weight: 600;
    font-family: inherit;
}

.highlight-row td {
    background-color: rgba(243, 156, 18, 0.12) !important;
    color: var(--dark-grey);
    font-weight: 700;
}

.summary-text {
    text-align: center;
    font-weight: 600;
    margin-top: 15px;
    margin-bottom: 30px;
    font-size: 1.1em;
    color: var(--primary-color);
    padding: 10px;
    background-color: rgba(41, 128, 185, 0.05);
    border-radius: 8px;
    box-shadow: var(--input-shadow);
}

/* --- Profit/Loss Text Colors --- */
.text-profit {
    color: var(--profit-color) !important;
    font-weight: 600;
}

.text-loss {
    color: var(--loss-color) !important;
    font-weight: 600;
}

#initialMessage {
    padding: 60px 30px;
    background: linear-gradient(to bottom right, var(--white), rgba(255, 253, 231, 0.3));
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
}

#initialMessage h2 {
    color: var(--primary-color);
    font-size: 2em;
    margin-bottom: 20px;
    font-family: 'League Spartan';
}

#initialMessage p {
    font-size: 1.2em;
    color: var(--dark-grey);
    margin-bottom: 20px;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1200px) {
    .calculator-wrapper {
        margin: 10px;
        border-radius: 8px;
    }
    
    #sidebar {
        width: 350px;
    }
}

@media (max-width: 900px) {
    .calculator-wrapper {
        flex-direction: column;
        margin: 0;
        border-radius: 0;
    }
    
    #sidebar {
        width: 100% !important;
        position: relative !important;
        border-right: none;
        border-bottom: 1px solid var(--medium-grey);
        padding: 20px;
        height: auto;
        max-height: none;
        overflow-y: visible;
        background-image: none;
    }
    
    #main-content {
        padding: 20px;
        width: 100% !important;
    }
    
    .sidebar-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-bottom: 15px;
    }
    
    .sidebar-header:after {
        left: 50%;
        transform: translateX(-50%);
        width: 120px;
    }
    
    .sidebar-logo {
        margin: 0 auto 10px;
    }
    
    .company-name, .sidebar-header p {
        text-align: center;
    }
    
    .input-form h2 {
        text-align: center;
        margin-top: 30px;
    }
    
    .results-section {
        padding: 15px;
    }
    
    #main-content h2 {
        font-size: 1.5em;
    }
    
    #main-content h3 {
        font-size: 1.2em;
        margin-top: 30px;
    }
    
    .data-table th, .data-table td {
        padding: 10px 12px;
    }
    
    /* Two-column layout for inputs on tablets */
    .input-form {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0 20px;
    }
    
    .input-form h2, .input-form button, .error-message {
        grid-column: span 2;
    }
}

/* Small tablets and large phones */
@media (max-width: 768px) {
    body {
        font-size: 15px;
    }
    
    .input-form {
        display: block;
    }
    
    .results-section {
        margin-top: 0;
        padding: 12px;
    }
    
    #initialMessage {
        padding: 30px 20px;
        margin: 15px;
    }
    
    #initialMessage h2 {
        font-size: 1.6em;
    }
    
    #initialMessage p {
        font-size: 1em;
    }
    
    .input-form label {
        font-size: 1em;
    }
    
    .input-form input[type="number"], 
    .input-form select {
        font-size: 1em;
        padding: 10px 12px;
    }
    
    .input-form button {
        padding: 12px;
        font-size: 1em;
    }
    
    /* Handle table overflow */
    .data-table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Wrap tables in this container */
    #monthlyCostsComparison, #breakevenAnalysis {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 20px;
    }
    
    .data-table {
        min-width: 500px; /* Ensure minimum width for readability */
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    .calculator-wrapper {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    
    #sidebar {
        padding: 15px;
    }
    
    #main-content {
        padding: 15px;
    }
    
    .sidebar-header {
        margin-bottom: 20px;
    }
    
    .sidebar-logo {
        max-width: 240px;
    }
    
    /* Enlarge company name and tagline on mobile */
    .sidebar-header .company-name {
        font-size: 1.4em;
    }
    .sidebar-header p:not(.company-name) {
        font-size: 1.2em;
    }

    .input-group {
        margin-bottom: 16px;
    }
    
    .input-form h2 {
        font-size: 1.2em;
        margin-bottom: 20px;
        margin-top: 25px;
    }
    
    .input-form label {
        margin-bottom: 6px;
    }
    
    .input-form input[type="number"], 
    .input-form select {
        padding: 8px 10px;
        border-radius: 6px;
    }
    
    .input-form button {
        margin-top: 25px;
        padding: 10px;
    }
    
    .error-message {
        font-size: 0.85em;
        padding: 10px;
    }
    
    #main-content h2 {
        font-size: 1.3em;
        margin-bottom: 20px;
    }
    
    #main-content h2:after {
        width: 60px;
        height: 2px;
    }
    
    #main-content h3 {
        font-size: 1.1em;
        margin-top: 25px;
        margin-bottom: 15px;
    }
    
    .data-table th, .data-table td {
        padding: 8px 10px;
        font-size: 0.9em;
    }
    
    .summary-text {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
}

/* Handle landscape orientation for phones */
@media (max-height: 500px) and (orientation: landscape) {
    #sidebar {
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .sidebar-header {
        padding-bottom: 10px;
        margin-bottom: 15px;
    }
    
    .input-form h2 {
        margin-top: 15px;
        margin-bottom: 15px;
    }
    
    .input-group {
        margin-bottom: 12px;
    }
    
    .input-form button {
        margin-top: 15px;
    }
}

/* Add wrapper class for tables to handle overflow on mobile */
.data-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 30px;
    /* Better mobile scrolling experience */
    scrollbar-width: thin;
    padding-bottom: 5px; /* Space for the scrollbar */
}

/* Show horizontal scroll indicator on mobile */
@media (max-width: 768px) {
    .data-table-wrapper {
        position: relative;
    }
    
    .data-table-wrapper:after {
        content: '';
        position: absolute;
        bottom: 0;
        right: 0;
        width: 50px;
        height: 100%;
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.7));
        pointer-events: none;
        z-index: 1;
    }
    
    .data-table {
        min-width: 650px; /* Ensure table has enough width to be scrollable */
    }
} 