/* ============================================
   Ray2Volt Toolbox - Minimalistic Clean Design
   ============================================ */

/* --- Design Tokens --- */
:root {
    /* Colors - Softer contrast with cyan accent */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-accent: #F0F7FF;
    --text-primary: #1A1A2E;
    --text-secondary: #4A4A68;
    --text-muted: #6E6E8A;
    --accent: #00B4D8;
    --accent-light: #E8F8FB;
    --accent-dark: #0096B4;
    --success: #00C853;
    --border-color: #D0D5DD;
    --border-light: #E8E8EE;

    /* Typography */
    --font-heading: 'Google Sans Flex', 'Montserrat', sans-serif;
    --font-body: 'Nunito Sans', sans-serif;

    /* Spacing & Radius */
    --sidebar-width: 260px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
}

/* --- Global Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
    overflow: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

/* ============================================
   LAYOUT
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- FIXED SIDEBAR --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.logo-header {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.logo-header .logo {
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
    object-fit: contain;
}

.logo-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

/* Navigation */
.main-nav ul {
    list-style: none;
}

.main-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid transparent;
    transition: all 0.15s ease;
}

.main-nav li a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.main-nav li a:hover {
    color: var(--text-primary);
    background-color: var(--accent-light);
    border-radius: var(--radius-sm);
}

.main-nav li a.active {
    color: var(--bg-primary);
    background-color: var(--accent);
    font-weight: 600;
    border-radius: var(--radius-sm);
}

/* Mobile Navigation Elements (hidden on desktop) */
.mobile-header {
    display: none;
}

.sidebar-close-btn {
    display: none;
}

.overlay {
    display: none;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    background-color: var(--bg-secondary);
    min-height: 100vh;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================
   DASHBOARD
   ============================================ */

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    margin-bottom: 0.25rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.tool-card {
    background-color: var(--bg-primary);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.tool-card:hover {
    background-color: var(--accent-light);
    border-color: var(--accent);
}

.tool-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.tool-card:hover p {
    color: var(--text-secondary);
}

/* ============================================
   CALCULATOR PANELS
   ============================================ */

.calculator-panel {
    background-color: var(--bg-primary);
    padding: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.calculator-panel h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* --- Form Elements --- */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* Sliders */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    margin-top: 0.75rem;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    cursor: pointer;
    border: none;
    border-radius: 50%;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.btn {
    padding: 0.6rem 1rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

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

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

/* Control Groups */
.control-group {
    margin-top: 1.5rem;
}

.control-group strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.input-help {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   OUTPUT SECTIONS
   ============================================ */

.output-section {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background-color: var(--bg-accent);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.output-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

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

.output-item span:first-child {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.output-item span:last-child {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.output-item.total-highlight {
    background-color: var(--accent-light);
    margin: 0.5rem -1.25rem -1.25rem;
    padding: 1rem 1.25rem;
    border-bottom: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ============================================
   EMI CALCULATOR SPECIFICS
   ============================================ */

.emi-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

#emiChartContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 220px;
    margin-top: 1rem;
}

/* Amortization Table */
.amortization-table-container {
    margin-top: 2rem;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.6rem 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}

th {
    background-color: var(--accent);
    color: var(--text-primary);
    position: sticky;
    top: 0;
    font-weight: 600;
    font-size: 0.85rem;
}

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

/* EMI Calculation Mode */
.calc-mode-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.calc-mode-buttons {
    gap: 0.5rem;
}

.calc-mode-buttons .btn {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.75rem;
}

.fixed-emi-group {
    margin-bottom: 1.5rem;
}

.input-highlight {
    border-color: var(--accent) !important;
    background-color: var(--accent-light) !important;
    box-shadow: 0 0 0 3px var(--accent-light);
}

.input-highlight:focus {
    box-shadow: 0 0 0 3px var(--accent-light);
}

.result-highlight {
    color: var(--success) !important;
    font-weight: 700 !important;
}

.calculated-result {
    background-color: var(--accent-light);
    padding: 0.75rem 1rem !important;
    border: 1px solid var(--accent);
    margin-bottom: 0.5rem;
}

.input-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================
   GST CALCULATOR SPECIFICS
   ============================================ */

#gst-breakdown {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-light);
}

/* ============================================
   PRICING CALCULATOR SPECIFICS
   ============================================ */

.pricing-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
}

.output-section-pricing {
    background: var(--bg-primary);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.output-section-pricing h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.pricing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-light);
}

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

.item-label {
    line-height: 1.4;
}

.label-main {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.label-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

#profitMarginPercentText {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.item-price {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.pricing-item.subtotal {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pricing-item.subtotal .label-main,
.pricing-item.subtotal .item-price {
    font-weight: 700;
}

.pricing-item.final-total {
    background-color: var(--accent);
    margin: 0.5rem -1.5rem -1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: none;
}

.pricing-item.final-total .label-main {
    font-weight: 700;
    font-size: 1rem;
}

.pricing-item.final-total .item-price {
    font-size: 1.25rem;
    font-weight: 700;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (max-width: 1024px) {

    .emi-layout,
    .pricing-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .main-content {
        padding: 1.5rem;
    }

    .calculator-panel {
        padding: 1.5rem;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .app-container {
        flex-direction: column;
    }

    /* Mobile Header */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        background-color: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-logo {
        height: 36px;
    }

    .mobile-nav-toggle {
        background: none;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        padding: 0.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-nav-toggle svg {
        width: 24px;
        height: 24px;
        color: var(--text-primary);
    }

    /* Sidebar becomes drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        border-right: 1px solid var(--border-color);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: block;
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        background: none;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        font-size: 1.5rem;
        padding: 0.25rem 0.5rem;
        cursor: pointer;
        line-height: 1;
    }

    .overlay {
        display: block;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.25s ease;
    }

    .overlay.is-active {
        opacity: 1;
        visibility: visible;
    }

    /* Main Content - no margin */
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    /* Section Headers */
    .section-header h1 {
        font-size: 1.5rem;
    }

    .section-header p {
        font-size: 0.9rem;
    }

    /* Tool Grid */
    .tool-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tool-card {
        padding: 1.25rem;
    }

    /* Calculator Panel */
    .calculator-panel {
        padding: 1rem;
    }

    .calculator-panel h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }

    /* Input Groups */
    .input-group {
        margin-bottom: 1.25rem;
    }

    .input-group label {
        font-size: 0.85rem;
    }

    .input-field {
        padding: 0.65rem 0.75rem;
        font-size: 0.95rem;
    }

    /* Calculation Mode Buttons - Stack on mobile */
    .calc-mode-group {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .calc-mode-buttons {
        flex-direction: column;
    }

    .calc-mode-buttons .btn {
        width: 100%;
        padding: 0.6rem;
        font-size: 0.8rem;
    }

    /* Regular Button Groups */
    .button-group {
        gap: 0.4rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Control Groups */
    .control-group {
        margin-top: 1.25rem;
    }

    .control-group strong {
        font-size: 0.85rem;
    }

    .input-help {
        font-size: 0.75rem;
    }

    /* Output Section */
    .output-section {
        margin-top: 1.25rem;
        padding: 1rem;
    }

    .output-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.6rem 0;
    }

    .output-item span:first-child {
        font-size: 0.85rem;
    }

    .output-item span:last-child {
        align-self: flex-end;
        font-size: 1.2rem;
    }

    .output-item.total-highlight {
        margin: 0.5rem -1rem -1rem;
        padding: 0.75rem 1rem;
    }

    .calculated-result {
        padding: 0.6rem 0.75rem !important;
    }

    /* Fixed EMI Group */
    .fixed-emi-group {
        margin-bottom: 1rem;
    }

    /* EMI Chart */
    #emiChartContainer {
        min-height: 180px;
    }

    /* Amortization Table */
    .amortization-table-container {
        margin-top: 1.5rem;
        max-height: 300px;
        overflow-x: auto;
        border-radius: var(--radius-sm);
    }

    table {
        font-size: 0.8rem;
    }

    th,
    td {
        padding: 0.5rem;
        white-space: nowrap;
    }

    th {
        font-size: 0.75rem;
    }

    /* Pricing Layout */
    .pricing-layout {
        gap: 1.5rem;
    }

    .output-section-pricing {
        padding: 1rem;
    }

    .output-section-pricing h3 {
        font-size: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.6rem;
    }

    .pricing-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.5rem 0;
    }

    .label-main {
        font-size: 0.85rem;
    }

    .label-sub {
        font-size: 0.7rem;
    }

    .item-price {
        align-self: flex-end;
        font-size: 0.95rem;
    }

    .pricing-item.subtotal {
        padding-top: 0.75rem;
    }

    .pricing-item.final-total {
        margin: 0.5rem -1rem -1rem;
        padding: 0.75rem 1rem;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
    }

    .pricing-item.final-total .label-main {
        font-size: 0.95rem;
    }

    .pricing-item.final-total .item-price {
        font-size: 1.15rem;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE (iPhone SE, etc)
   ============================================ */

@media (max-width: 375px) {
    .main-content {
        padding: 0.75rem;
    }

    .calculator-panel {
        padding: 0.75rem;
    }

    .calculator-panel h2 {
        font-size: 1.1rem;
    }

    .btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .output-item span:last-child {
        font-size: 1.1rem;
    }
}