/* =========================================================
   PAGE
   ========================================================= */

.ajax-calculator-page {

    width: 100%;

    max-width: 1250px;

    margin: 0 auto;

    padding: 12px;

}


.ajax-calculator-card {

    background: #fff;

    border-radius: 18px;

    box-shadow:
        0 5px 24px rgba(0,0,0,.08);

    padding: 20px;

    margin-bottom: 20px;

}

/* =========================================================
   FULL VIEW BUTTON
   ========================================================= */

.ajax-calculator-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.ajax-calculator-title-main {
    min-width: 0;
}

.ajax-fullscreen-button {
    flex-shrink: 0;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ajax-fullscreen-button:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.ajax-fullscreen-button:active {
    transform: translateY(1px);
}

/* Fullscreen calculator */

.ajax-calculator-page:fullscreen {
    width: 100%;
    min-height: 100vh;
    overflow-y: auto;
    background: #ffffff;
    padding: 20px;
    box-sizing: border-box;
}

.ajax-calculator-page:fullscreen .ajax-calculator-card {
    width: 100%;
    max-width: none;
    margin: 0 auto;
}

/* Browser prefixes */

.ajax-calculator-page:-webkit-full-screen {
    width: 100%;
    min-height: 100vh;
    overflow-y: auto;
    background: #ffffff;
    padding: 20px;
    box-sizing: border-box;
}

/* Mobile */

@media (max-width: 600px) {

    .ajax-calculator-title {
        align-items: flex-start;
    }

    .ajax-fullscreen-button {
        padding: 8px 10px;
    }

    .ajax-fullscreen-button span {
        display: none;
    }

}

/* =========================================================
   TITLE
   ========================================================= */

.ajax-calculator-title {

    text-align: center;

    margin:
        2px
        0
        22px;

}


.ajax-calculator-title h1 {

    font-size:
        clamp(23px, 3vw, 32px);

    line-height: 1.25;

    margin: 0;

}


.ajax-calculator-subtitle {

    color: #6c757d;

    font-size: 14px;

    margin-top: 7px;

}


/* =========================================================
   TWO COLUMN
   ========================================================= */

.ajax-calculator-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 3fr)
        minmax(0, 2fr);
    gap: 20px;
    align-items: start;
}


.ajax-panel {

    min-width: 0;

    border:
        1px solid #e3e7eb;

    border-radius: 14px;

    overflow: hidden;

    background: #fff;

}


.ajax-input-panel {

    background: #fbfcfd;

}


.ajax-result-panel {

    position: sticky;

    top: 15px;

    box-shadow:
        0 5px 18px rgba(0,0,0,.06);

}


/* =========================================================
   PANEL HEADER
   ========================================================= */

.ajax-panel-header {

    min-height: 66px;

    padding:
        12px
        16px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    border-bottom:
        1px solid #e5e9ed;

    background:
        linear-gradient(
            to bottom,
            #ffffff,
            #f8fafc
        );

}


.ajax-panel-icon {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 30px;

    height: 30px;

    margin-right: 8px;

    border-radius: 50%;

    background: #eef4ff;

    color: #0d6efd;

    font-size: 12px;

    font-weight: 700;

    vertical-align: middle;

}


.ajax-panel-title {

    display: inline-block;

    font-size: 19px;

    font-weight: 700;

    vertical-align: middle;

}


.ajax-panel-caption {

    color: #6c757d;

    font-size: 12px;

    white-space: nowrap;

}


.ajax-result-intro {

    padding:
        11px
        16px
        4px;

    color: #6c757d;

    font-size: 13px;

}


/* =========================================================
   INPUT TABLE
   ========================================================= */
.ajax-form-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ajax-form-table th,
.ajax-form-table td {
    padding: 9px 10px;
    border-bottom: 0;
    vertical-align: middle;
}

/* =========================================================
   INPUT TABLE COLUMNS
   Works with BOTH:
   1. col-label / col-value / col-remark classes
   2. plain TH / TD tables
   ========================================================= */

.ajax-form-table th,
.ajax-form-table td {
    vertical-align: middle;
}

/* FIRST COLUMN — DESCRIPTION
   Automatically uses remaining space */
.ajax-form-table th:first-child {
    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

/* SECOND COLUMN — VALUE / INPUT
   FIXED */
.ajax-form-table td:nth-child(2) {
    width: 18%;
    text-align: center;
}

/* THIRD COLUMN — UNIT / REMARK
   FIXED */
.ajax-form-table td:nth-child(3) {
    width: 20%;
    text-align: center;
}


/* =========================================================
   INPUT
   ========================================================= */

.ajax-input {

    width: 100%;

    max-width: 125px;

    min-height: 40px;

    padding:
        7px
        9px;

    border:
        1px solid #cbd3da;

    border-radius: 7px;

    background: #fff;

    font-size: 15px;

    text-align: right;

    box-sizing: border-box;

    transition:
        border-color .15s,
        box-shadow .15s,
        background .15s;

}


.ajax-input:hover {

    border-color: #aeb8c2;

}


.ajax-input:focus {

    outline: none;

    border-color: #0d6efd;

    box-shadow:
        0 0 0 3px
        rgba(13,110,253,.12);

    background: #fff;

}


/* =========================================================
   LIVE BADGE
   ========================================================= */

.ajax-live-badge {

    display: inline-flex;

    align-items: center;

    gap: 6px;

    padding:
        5px
        9px;

    border-radius: 20px;

    background: #eef8f1;

    color: #238443;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: .04em;

}


.ajax-live-dot {

    width: 7px;

    height: 7px;

    border-radius: 50%;

    background: #2da44e;

    box-shadow:
        0 0 0 3px
        rgba(45,164,78,.12);

}

.ajax-live-badge.offline {

    background: #fff0f0;

    color: #dc3545;

}

.ajax-live-badge.offline .ajax-live-dot {

    background: #dc3545;

    box-shadow:
        0 0 0 3px
        rgba(220,53,69,.12);

}

/* =========================================================
   RESULT TABLE
   ========================================================= */

.ajax-result-table {

    width: 100%;

    border-collapse: collapse;

    table-layout: fixed;

    margin-top: 7px;

}


.ajax-result-table th,
.ajax-result-table td {

    padding:
        12px
        12px;

    border-bottom:
        1px solid #e9edf0;

    vertical-align: middle;

}


.ajax-result-table .result-label {
    width: 60%;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.ajax-result-table .result-value {
    width: 20%;
    text-align: right;
    font-weight: 800;
    font-size: 17px;
    white-space: nowrap;
}

.ajax-result-table .result-remark {
    width: 20%;
    text-align: left;
    color: #6c757d;
    font-size: 12px;
}


.ajax-result-table tr.result-highlight {

    background: #f6f9ff;

}


.ajax-result-table
tr.result-highlight
.result-value {

    color: #0d6efd;

    font-size: 19px;

}


/* =========================================================
   FOOTER
   ========================================================= */

.ajax-result-footer {

    display: flex;

    justify-content: space-between;

    gap: 10px;

    padding:
        12px
        16px;

    color: #7a838c;

    background: #fafbfc;

    font-size: 11px;

}


/* =========================================================
   STATUS
   ========================================================= */

.ajax-live-status {

    min-height: 21px;

    padding:
        6px
        10px
        0;

    text-align: center;

    font-size: 12px;

    color: #6c757d;

}


.ajax-live-status.calculating {

    color: #0d6efd;

}


.ajax-live-status.error {

    color: #dc3545;

}


/* =========================================================
   BUTTONS
   ========================================================= */

.ajax-action-row {

    display: flex;

    justify-content: center;

    gap: 8px;

    flex-wrap: wrap;

    padding: 12px;

}


.ajax-action-button {

    min-height: 40px;

    padding:
        8px
        17px;

    border: 0;

    border-radius: 7px;

    cursor: pointer;

    font-size: 14px;

}


.ajax-button-primary {

    background: #0d6efd;

    color: #fff;

}


.ajax-button-secondary {

    background: #6c757d;

    color: #fff;

}


/* =========================================================
   LOWER CONTENT
   ========================================================= */

.ajax-lower-section {

    margin-top: 22px;

}


.ajax-section-title {

    font-size: 18px;

    font-weight: 700;

    margin:
        18px
        0
        10px;

    padding-bottom: 7px;

    border-bottom:
        2px solid #e9edf0;

}


.ajax-remarks-box {

    padding:
        13px
        15px;

    border:
        1px solid #e5e9ed;

    border-radius: 10px;

    background: #fafbfc;

    color: #5f6872;

    font-size: 13px;

}


.ajax-remarks-box p:last-child {

    margin-bottom: 0;

}


.ajax-related {

    text-align: center;

    margin:
        22px
        0
        5px;

}


.ajax-related a {

    display: inline-block;

    margin: 4px;

}


/* =========================================================
   LOADING
   ========================================================= */

.ajax-loading {

    display: inline-block;

    width: 12px;

    height: 12px;

    border:
        2px solid currentColor;

    border-right-color:
        transparent;

    border-radius: 50%;

    animation:
        ajaxSpin .7s linear infinite;

    vertical-align: -2px;

    margin-right: 5px;

}


@keyframes ajaxSpin {

    to {

        transform:
            rotate(360deg);

    }

}

/* =====================================================
   MOBILE
   ===================================================== */

@media (max-width: 850px) {

    /* =====================================================
       STACK LEFT + RIGHT PANELS
       ===================================================== */

    .ajax-calculator-page {
        width: 100%;
        max-width: 100%;
        padding: 7px;
        box-sizing: border-box;
    }

    .ajax-calculator-card {
        width: 100%;
        max-width: 100%;
        padding: 10px;
        box-sizing: border-box;
        border-radius: 13px;
    }

    .ajax-calculator-grid {
        width: 100%;
        max-width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .ajax-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .ajax-result-panel {
        position: static;
    }


    /* =====================================================
       LEFT / INPUT TABLE
       NO HORIZONTAL LINES
       ===================================================== */

    .ajax-form-table,
    .ajax-form-table tbody,
    .ajax-form-table tr,
    .ajax-form-table th,
    .ajax-form-table td {
        display: block;
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box;
    }

    .ajax-form-table thead {
        display: none;
    }

    .ajax-form-table tr {
        padding: 9px 10px;
        border-bottom: 0 !important;
    }

    .ajax-form-table th,
    .ajax-form-table td {
        border-bottom: 0 !important;
    }


    /* FIRST COLUMN — DESCRIPTION */

    .ajax-form-table th:first-child {
        width: 100% !important;
        padding: 3px 0;

        font-weight: 600;
        font-size: 13px;
        line-height: 1.35;

        text-align: left !important;

        white-space: normal;
        overflow-wrap: break-word;
        word-break: normal;
    }


    /* SECOND COLUMN — INPUT */

    .ajax-form-table td:nth-child(2) {
        width: 100% !important;
        padding: 3px 0;

        text-align: center !important;
    }

    .ajax-form-table td:nth-child(2) .ajax-input {
        display: block;

        width: 100%;
        max-width: none;
        min-width: 0;

        margin: 0 auto;

        text-align: center;
        font-size: 16px;

        box-sizing: border-box;
    }


    /* THIRD COLUMN — UNIT */

    .ajax-form-table td:nth-child(3) {
        display: block !important;

        width: 100% !important;

        padding: 3px 0 !important;

        text-align: center !important;

        color: #777;
        font-size: 11px;
    }


    /* =====================================================
       RIGHT / RESULT TABLE
       KEEP HORIZONTAL LINES
       ===================================================== */

    .ajax-result-table {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .ajax-result-table th,
    .ajax-result-table td {
        box-sizing: border-box;
    }
    
    /* RIGHT / RESULT TABLE */

    .ajax-result-table td:nth-child(2) {
        text-align: center !important;
    }

    .ajax-result-table td:nth-child(3) {
        text-align: center !important;
    }


    
    

}


/* =========================================================
   PRINT
   ========================================================= */

@media print {


    #sidebar,
    .navbar,
    .no-print,
    .ajax-live-status,
    .ajax-related,
    .ajax-lower-section {

        display: none !important;

    }


    .ajax-calculator-page {

        max-width: none;

        padding: 0;

    }


    .ajax-calculator-card {

        box-shadow: none;

        border: 0;

        padding: 0;

    }


    .ajax-calculator-grid {

        display: grid;

        grid-template-columns: 1fr 1fr;

    }


    .ajax-result-panel {

        position: static;

    }

}


/* =========================================================
   DARK MODE SUPPORT
   ========================================================= */

html[data-theme="dark"] .ajax-calculator-card,
html.dark .ajax-calculator-card,
body.dark .ajax-calculator-card {

    background: #1e1e1e;
    color: #f1f1f1;

}


html[data-theme="dark"] .ajax-panel,
html.dark .ajax-panel,
body.dark .ajax-panel {

    background: #242424;
    border-color: #444;

}


html[data-theme="dark"] .ajax-input-panel,
html.dark .ajax-input-panel,
body.dark .ajax-input-panel {

    background: #202020;

}


html[data-theme="dark"] .ajax-panel-header,
html.dark .ajax-panel-header,
body.dark .ajax-panel-header {

    background: linear-gradient(
        to bottom,
        #292929,
        #222222
    );

    border-bottom-color: #444;

}


html[data-theme="dark"] .ajax-panel-title,
html.dark .ajax-panel-title,
body.dark .ajax-panel-title {

    color: #f1f1f1;

}


html[data-theme="dark"] .ajax-panel-caption,
html.dark .ajax-panel-caption,
body.dark .ajax-panel-caption {

    color: #b8b8b8;

}


html[data-theme="dark"] .ajax-calculator-title h1,
html.dark .ajax-calculator-title h1,
body.dark .ajax-calculator-title h1 {

    color: #f5f5f5;

}


html[data-theme="dark"] .ajax-calculator-subtitle,
html.dark .ajax-calculator-subtitle,
body.dark .ajax-calculator-subtitle {

    color: #b8b8b8;

}


/* Input table */

html[data-theme="dark"] .ajax-form-table th,
html.dark .ajax-form-table th,
body.dark .ajax-form-table th {

    background: #303030;
    color: #dcdcdc;
    border-bottom-color: #444;

}


html[data-theme="dark"] .ajax-form-table td,
html.dark .ajax-form-table td,
body.dark .ajax-form-table td {

    color: #eeeeee;
    border-bottom-color: #3d3d3d;

}


/* Input boxes */

html[data-theme="dark"] .ajax-input,
html.dark .ajax-input,
body.dark .ajax-input {

    background: #181818;
    color: #ffffff;

    border-color: #555;

}


html[data-theme="dark"] .ajax-input:hover,
html.dark .ajax-input:hover,
body.dark .ajax-input:hover {

    border-color: #777;

}


html[data-theme="dark"] .ajax-input:focus,
html.dark .ajax-input:focus,
body.dark .ajax-input:focus {

    background: #181818;
    color: #ffffff;

}


/* Result text */

html[data-theme="dark"] .ajax-result-intro,
html.dark .ajax-result-intro,
body.dark .ajax-result-intro {

    color: #bdbdbd;

}


html[data-theme="dark"] .ajax-result-table th,
html.dark .ajax-result-table th,
body.dark .ajax-result-table th {

    color: #eeeeee;
    border-bottom-color: #3d3d3d;

}


html[data-theme="dark"] .ajax-result-table td,
html.dark .ajax-result-table td,
body.dark .ajax-result-table td {

    color: #eeeeee;
    border-bottom-color: #3d3d3d;

}


html[data-theme="dark"] .ajax-result-table .result-remark,
html.dark .ajax-result-table .result-remark,
body.dark .ajax-result-table .result-remark {

    color: #b8b8b8;

}


/* Highlighted results */

html[data-theme="dark"]
.ajax-result-table tr.result-highlight,
html.dark
.ajax-result-table tr.result-highlight,
body.dark
.ajax-result-table tr.result-highlight {

    background: #202a38;

}


html[data-theme="dark"]
.ajax-result-table
tr.result-highlight
.result-value,
html.dark
.ajax-result-table
tr.result-highlight
.result-value,
body.dark
.ajax-result-table
tr.result-highlight
.result-value {

    color: #5da9ff;

}


/* Result footer */

html[data-theme="dark"] .ajax-result-footer,
html.dark .ajax-result-footer,
body.dark .ajax-result-footer {

    background: #202020;
    color: #a8a8a8;

}


/* Status */

html[data-theme="dark"] .ajax-live-status,
html.dark .ajax-live-status,
body.dark .ajax-live-status {

    color: #b8b8b8;

}


html[data-theme="dark"] .ajax-live-status.calculating,
html.dark .ajax-live-status.calculating,
body.dark .ajax-live-status.calculating {

    color: #5da9ff;

}


html[data-theme="dark"] .ajax-live-status.error,
html.dark .ajax-live-status.error,
body.dark .ajax-live-status.error {

    color: #ff6b6b;

}


/* Remarks */

html[data-theme="dark"] .ajax-section-title,
html.dark .ajax-section-title,
body.dark .ajax-section-title {

    color: #f1f1f1;
    border-bottom-color: #444;

}


html[data-theme="dark"] .ajax-remarks-box,
html.dark .ajax-remarks-box,
body.dark .ajax-remarks-box {

    background: #202020;
    border-color: #444;
    color: #c8c8c8;

}


/* Live / Offline badge */

html[data-theme="dark"] .ajax-live-badge,
html.dark .ajax-live-badge,
body.dark .ajax-live-badge {

    background: #173523;
    color: #69d58a;

}


html[data-theme="dark"] .ajax-live-badge.offline,
html.dark .ajax-live-badge.offline,
body.dark .ajax-live-badge.offline {

    background: #3a2022;
    color: #ff7272;

}


/* Panel icons */

html[data-theme="dark"] .ajax-panel-icon,
html.dark .ajax-panel-icon,
body.dark .ajax-panel-icon {

    background: #263a55;
    color: #62a9ff;

}

/* =========================================================
   FIRST COLUMN — DESCRIPTION
   Flexible width + text wrapping
   ========================================================= */

.ajax-form-table th:first-child,
.ajax-form-table td:first-child,
.ajax-result-table th:first-child,
.ajax-result-table td:first-child {

    width: auto;

    text-align: left;

    white-space: normal;

    overflow-wrap: anywhere;

    word-break: normal;

    min-width: 0;
}

