/**
 * Divine SIP Calculator Styles
 * 
 * Main stylesheet for the calculator layout, charts, and responsive design.
 * 
 * @package DivineSIPCalculator
 */

/* =========================================
   1. CSS Variables (Color Palette)
   ========================================= */
:root {
    /* Brand / Primary Color */
    --dpsip-primary: #009959;

    /* Text Colors */
    --dpsip-text-main: #010101;
    --dpsip-text-secondary: #6b7280;

    /* Backgrounds */
    --dpsip-bg-main: #F2F2F2;
    --dpsip-bg-white: #FFFFFF;
    --dpsip-bg-hover: #f3f4f6;

    /* Borders & UI Elements */
    --dpsip-border: #D9D9D9;
    --dpsip-toggle-inactive: #cbd5e1;
    --dpsip-scrollbar-track: #e0e0e0;
}

/* =========================================
   2. Global Reset for Plugin
   ========================================= */
.dp-sip-container * {
    box-sizing: border-box;
}

/* =========================================
   3. Main Layout & Cards
   ========================================= */

/* Main Container Card */
.dp-sip-main-card {
    overflow-x: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 44px;
    background: var(--dpsip-bg-main);
    padding: 60px;
    border-radius: 12px;
    margin-bottom: 40px;
}

/* Layout: Label Rows */
.dp-sip-label-row {
    display: grid;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    grid-template-columns: 1fr 265px;
}

/* Layout: Left Section (Inputs) */
.dp-sip-left-section {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* =========================================
   4. Buttons & Toggles
   ========================================= */

/* Toggle Buttons (SIP vs Lumpsum) */
.dp-sip-toggle-row {
    display: flex;
    gap: 12px;
}

.dp-sip-toggle-row .dp-sip-toggle-btn {
    background-image: none;
    background: var(--dpsip-bg-white);
    border: none;
    padding: 10px 20px;
    color: var(--dpsip-text-main);
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    font-weight: 500;
    font-size: 16px;
    line-height: 1.5em;
    vertical-align: middle;
}

.dp-sip-toggle-btn.dp-sip-active {
    color: var(--dpsip-bg-white);
    background: var(--dpsip-primary);
}

/* Utility Classes */
.dp-sip-form-row.dp-sip-hidden {
    display: none !important;
}

.dp-sip-form-row label {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.5em;
    color: var(--dpsip-text-main);
}

/* =========================================
   5. Inputs & Dropdowns
   ========================================= */

.dp-sip-dropdown-wrapper {
    position: relative;
}

.dp-sip-label-row .dp-sip-dropdown-wrapper .dp-sip-dropdown-btn,
.dp-sip-dropdown-wrapper .dp-sip-investment-input-wrapper,
.dp-sip-form-row .dp-sip-label-row .dp-sip-step-value,
.dp-sip-form-row .dp-sip-label-row .dp-sip-rate-badge {
    width: 100%;
    background: var(--dpsip-bg-white);
    border: 1px solid var(--dpsip-border);
    border-radius: 6px;
    padding: 16px 18px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: var(--dpsip-primary);
    background-image: none;
    box-sizing: border-box;
}

.dp-sip-rupee-symbol {
    font-size: 16px;
    font-weight: 500;
    color: var(--dpsip-primary);
}

/* Input Fields Styling */
.dp-sip-investment-input-wrapper .dp-sip-investment-input,
.dp-sip-main-card .dp-sip-step-value input,
.dp-sip-container .dp-sip-rate-badge input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    color: var(--dpsip-primary);
    text-align: end;
    min-width: 80px;
    padding: 0;
}

.dp-sip-step-value.dp-sip-disabled,
.dp-sip-rate-badge.dp-sip-disabled {
    opacity: .6;
    cursor: not-allowed;
}

/* Dropdown Content */
.dp-sip-dropdown-content {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--dpsip-bg-white);
    border: 1px solid var(--dpsip-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgb(0 0 0 / .1);
    z-index: 100;
    min-width: 100%;
    padding: 10px;
    display: none;
}

.dp-sip-dropdown-content.dp-sip-show {
    display: block;
}

.dp-sip-dropdown-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 15px;
    color: var(--dpsip-text-main);
    transition: background 0.15s;
}

.dp-sip-dropdown-option:hover {
    background: var(--dpsip-bg-hover);
}

/* =========================================
   6. Sliders & Switches
   ========================================= */

/* Toggle Switch (Step Up) */
.dp-sip-toggle-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dp-sip-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.dp-sip-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.dp-sip-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--dpsip-toggle-inactive);
    transition: 0.3s;
    border-radius: 24px;
}

.dp-sip-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--dpsip-bg-white);
    transition: 0.3s;
    border-radius: 50%;
}

.dp-sip-toggle-switch input:checked+.dp-sip-toggle-slider {
    background-color: var(--dpsip-primary);
}

.dp-sip-toggle-switch input:checked+.dp-sip-toggle-slider:before {
    transform: translateX(20px);
}

/* Range Sliders */
.dp-sip-slider-row {
    margin-top: 8px;
    position: relative;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
}

.dp-sip-slider-container {
    position: absolute;
    width: 100%;
    height: 8px;
    top: 50%;
    transform: translateY(-50%);
}

.dp-sip-slider-track {
    position: absolute;
    width: 100%;
    height: 8px;
    background: var(--dpsip-border);
    border-radius: 4px;
    top: 0;
}

.dp-sip-slider-fill {
    position: absolute;
    height: 8px;
    background: var(--dpsip-primary);
    border-radius: 4px 0 0 4px;
    top: 0;
    left: 0;
    transition: width 0.1s ease;
}

.dp-sip-slider-row input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    outline: none;
    position: relative;
    z-index: 2;
    margin: 0;
    cursor: pointer;
}

.dp-sip-slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--dpsip-primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgb(0 0 0 / .15);
}

/* =========================================
   7. Chart Section
   ========================================= */

.dp-sip-right-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
}

/* Chart Container */
.dp-sip-chart-wrapper {
    position: relative;
    width: 320px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dp-sip-pie-chart-container {
    width: 320px;
    height: 320px;
    position: relative;
}

/* Custom Chart Legend */
.dp-sip-custom-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
    gap: 20px;
    width: 100%;
}

.dp-sip-legend-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--dpsip-text-main);
    cursor: pointer;
}

.dp-sip-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    margin-right: 8px;
}

/* Custom Tooltip */
#dpSipTooltip {
    opacity: 0;
    position: absolute;
    background: var(--dpsip-bg-white);
    color: #000;
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgb(0 0 0 / .2);
    font-size: 14px;
    font-weight: 400;
    transition: opacity 0.1s ease;
    white-space: nowrap;
    line-height: 1.3;
    z-index: 999;
    padding: 10px 12px;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: row;
    gap: 40px;
}

/* Summary Stats (Invested vs Returns) */
.dp-sip-summary-stats {
    width: 100%;
    margin-top: auto;
}

.dp-sip-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--dpsip-border);
}

.dp-sip-stat-row:last-child {
    border-bottom: none;
}

.dp-sip-stat-label {
    font-size: 16px;
    color: var(--dpsip-text-main);
    font-weight: 500;
}

.dp-sip-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--dpsip-text-main);
    text-align: right;
}

.dp-sip-stat-lacs {
    font-size: 14px;
    font-weight: 400;
    color: var(--dpsip-text-secondary);
}

/* =========================================
   8. Results Table
   ========================================= */

h5.dp-sip-table-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--dpsip-text-main);
    margin-bottom: 16px;
}

.dp-sip-table-section {
    background: var(--dpsip-bg-white);
    border-radius: 8px;
    text-align: center;
    padding-top: 40px;
}

.dp-sip-table-wrapper {
    border-radius: 13px;
    overflow: auto;
    border: 1px solid var(--dpsip-border);
}

.dp-sip-table-wrapper table {
    margin: 0;
    border-collapse: collapse;
    width: 100%;
}

.dp-sip-table-wrapper th,
.dp-sip-table-wrapper td {
    padding: 19px 22px;
    text-align: left;
    border: 1px solid var(--dpsip-border);
    font-size: 16px;
}

/* Table Stripes */
.dp-sip-table-wrapper table tbody>tr:nth-child(odd)>td,
.dp-sip-table-wrapper table tbody>tr:nth-child(odd)>th,
.dp-sip-table-wrapper table tbody tr:hover>td,
.dp-sip-table-wrapper table tbody tr:hover>th {
    background-color: unset;
}

/* Table Borders (General) */
.dp-sip-table-wrapper table caption+thead tr:first-child td,
.dp-sip-table-wrapper table caption+thead tr:first-child th,
.dp-sip-table-wrapper table colgroup+thead tr:first-child td,
.dp-sip-table-wrapper table colgroup+thead tr:first-child th,
.dp-sip-table-wrapper table thead:first-child tr:first-child td,
.dp-sip-table-wrapper table thead:first-child tr:first-child th {
    border: 1px solid var(--dpsip-border);
}

/* Table Borders (Clean Look Updates) */
.dp-sip-table-wrapper tr>th {
    border-top: 0 !important;
}

.dp-sip-table-wrapper tr>*:first-child {
    border-left: 0 !important;
}

.dp-sip-table-wrapper tr>*:last-child {
    border-right: 0 !important;
}

.dp-sip-table-wrapper tbody tr:last-child>* {
    border-bottom: 0 !important;
}

/* =========================================
   9. Custom Scrollbar (Scoped to Table)
   ========================================= */

/* Width */
.dp-sip-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

/* Track */
.dp-sip-table-wrapper::-webkit-scrollbar-track {
    box-shadow: inset 0 0 5px var(--dpsip-scrollbar-track);
    border-radius: 10px;
    background: var(--dpsip-bg-white);
}

/* Handle */
.dp-sip-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--dpsip-primary);
    border-radius: 10px;
}

/* Handle on hover */
.dp-sip-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #007f4a;
}

/* =========================================
   10. Responsive Design
   ========================================= */

@media (max-width: 1024px) {
    .dp-sip-main-card {
        margin-bottom: 50px;
        grid-template-columns: 1fr;
        gap: 40px;
    }

    /* Fixed chart ordering on tablets */
    .dp-sip-chart-wrapper {
        order: 1;
    }

    #dpSipTooltip {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 767px) {
    .dp-sip-main-card {
        padding: 30px 20px;
    }

    .dp-sip-label-row {
        grid-template-columns: 1fr;
    }

    .dp-sip-chart-wrapper {
        width: 100%;
        max-width: 270px;
    }

    .dp-sip-pie-chart-container {
        width: 270px;
        height: 270px;
    }

    .dp-sip-table-wrapper th,
    .dp-sip-table-wrapper td {
        padding: 10px 8px;
        font-size: 14px;
        min-width: 150px;
    }

    .dp-sip-stat-value {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
}

@media (max-width: 350px) {
    .dp-sip-pie-chart-container {
        width: 220px;
        height: 220px;
    }
}