/* FMCG Calculators — Swastik Marketing (backup grid layout + enhancements) */

/* ================= PAGE ================= */
.calc-page {
    padding-bottom: 48px;
}

.calc-body {
    padding-top: 22px;
}

/* ================= MOBILE TABS ================= */
.calc-tabs {
    display: none;
    gap: 8px;
    margin-bottom: 18px;
    padding: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: calc(var(--header-height) + 8px);
    z-index: 50;
}

.calc-tabs__btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    min-height: 44px;
    transition: background var(--transition), color var(--transition);
}

.calc-tabs__btn.is-active {
    background: var(--gradient-brand);
    color: #fff;
}

/* ================= GRID (BACKUP LAYOUT) ================= */
.grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    grid-template-areas:
        "currency diff right"
        "fmcg fmcg fmcg";
    gap: 20px;
    align-items: start;
}

.currency-card { grid-area: currency; }
.diff-card { grid-area: diff; }
.right-column { grid-area: right; }
.fmcg-pillar-card { grid-area: fmcg; }
.fmcg-mobile-wrapper { grid-area: fmcg; }

.right-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fmcg-pillar-card {
    display: block;
}

.fmcg-mobile-wrapper {
    display: none;
}

/* ================= CARD ================= */
.card {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
}

.card h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
    color: #292524;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.card-head h2 {
    margin: 0;
    flex: 1;
}

/* ================= SHARE IMAGE ================= */
.btn-share-image {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #86efac;
    background: #ecfdf5;
    color: #15803d;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-share-image:hover {
    background: #dcfce7;
}

.btn-share-image--block {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: 0.88rem;
}

.share-capture {
    background: #fff;
}

.share-capture--offscreen {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 900px;
    padding: 16px;
    z-index: -1;
}

.share-capture__title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #292524;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f97316;
}

.share-brand-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e7e5e4;
    font-size: 0.82rem;
    font-weight: 700;
    color: #9a3412;
    text-align: center;
}

.fmcg-table--capture {
    min-width: 0;
}

.fmcg-table--capture th,
.fmcg-table--capture td {
    font-size: 12px;
    padding: 8px 6px;
}

.mobile-share-bar {
    padding: 12px;
}

/* ================= SUMMARY ================= */
.summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f9fc;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: wrap;
}

/* ================= ACTIONS ================= */
.actions {
    text-align: right;
    margin-top: 10px;
}

.reset-btn {
    background: #6b7280;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 40px;
}

.reset-btn:hover {
    background: #4b5563;
}

.reset-btn--danger {
    background: #e11d48;
}

.reset-btn--danger:hover {
    background: #be123c;
}

.reset-btn.small {
    margin-top: 8px;
    padding: 6px 14px;
    font-size: 13px;
}

/* ================= CURRENCY TABLE ================= */
.note-table {
    width: 100%;
    border-collapse: collapse;
}

.note-table th,
.note-table td {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
}

.note-table th {
    background: #f7f9fc;
    font-weight: 600;
    font-size: 0.8rem;
}

.note-table input.qty {
    width: 70px;
    height: 40px;
    padding: 4px;
    text-align: center;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

/* ================= DISCOUNT ================= */
.discount-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.discount-grid label {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 600;
}

.discount-grid input {
    width: 100%;
    height: 42px;
    padding: 8px;
    font-size: 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.discount-footer {
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.discount-result {
    font-size: 1.25rem;
    font-weight: 700;
}

/* ================= DIFFERENCE ================= */
.diff-top {
    background: #f7f9fc;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.diff-highlight {
    font-size: 22px;
    font-weight: 700;
    margin: 8px 0;
}

.diff-inputs.vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-inputs.vertical input {
    height: 40px;
    padding: 8px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

/* ================= FMCG TABLE ================= */
.fmcg-pillar-card h2 {
    font-size: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.fmcg-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

.fmcg-table thead th {
    background: #0f172a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 8px;
    text-align: center;
    white-space: nowrap;
}

.fmcg-table tbody td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px;
    text-align: center;
}

.fmcg-table input {
    width: 100%;
    height: 36px;
    padding: 4px 6px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: center;
}

.fmcg-table input:focus {
    outline: none;
    border-color: #f97316;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.fmcg-table .net-rate {
    background: #ecfeff;
    font-weight: 700;
    color: #0f766e;
}

.fmcg-table .flat-percent {
    background: #fef3c7;
    font-weight: 700;
    color: #92400e;
}

.fmcg-table th:first-child,
.fmcg-table td:first-child {
    min-width: 180px;
    text-align: left;
}

.fmcg-table .product-name {
    text-align: left;
}

.table-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.table-actions button {
    background: #111827;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
}

.table-actions button:hover {
    background: #020617;
}

#resetAllBtn,
#resetMobileAll {
    background: #6b7280;
}

#resetAllBtn:hover,
#resetMobileAll:hover {
    background: #4b5563;
}

.btn-excel {
    background: #166534 !important;
}

.btn-excel:hover {
    background: #14532d !important;
}

/* ================= MOBILE FMCG ================= */
.fmcg-mobile-card {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.mobile-product-name {
    flex: 1;
    height: 42px;
    padding: 8px 10px;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.mobile-summary {
    text-align: right;
    flex-shrink: 0;
}

.mobile-summary .net-rate {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: #0f766e;
}

.mobile-summary .flat-percent {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #92400e;
}

.mobile-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-row label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
}

.mobile-row input {
    width: 100%;
    height: 42px;
    padding: 8px 10px;
    font-size: 15px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

.mobile-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mobile-actions button {
    flex: 1;
    min-width: 120px;
    background: #111827;
    color: #fff;
    border: none;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    min-height: 44px;
}

.mobile-actions .btn-excel {
    flex: 1 1 100%;
}

/* ================= TOAST ================= */
.calc-toast {
    position: fixed;
    bottom: 88px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #292524;
    color: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: min(90vw, 360px);
    text-align: center;
}

.calc-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ================= MOBILE ================= */
@media (max-width: 768px) {
    .calc-tabs {
        display: flex;
    }

    .grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "right"
            "currency"
            "fmcgmobile";
    }

    .fmcg-pillar-card {
        display: none !important;
    }

    .fmcg-mobile-wrapper {
        display: none;
        flex-direction: column;
        gap: 14px;
    }

    .desktop-only {
        display: none !important;
    }

    .flat-discount-card { order: 1; }
    .mrp-net-card { order: 2; }
    .buyxy-card { order: 3; }
    .currency-card { order: 4; }

    .right-column {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .discount-grid {
        grid-template-columns: 1fr;
    }

    /* Tab panels */
    #calcGrid [data-calc-section] {
        display: none;
    }

    #calcGrid[data-active-panel="discount"] .right-column {
        display: flex !important;
    }

    #calcGrid[data-active-panel="currency"] .currency-card {
        display: block;
    }

    #calcGrid[data-active-panel="margin"] .fmcg-mobile-wrapper {
        display: flex !important;
    }

    #calcGrid[data-active-panel="margin"] .right-column,
    #calcGrid[data-active-panel="margin"] .currency-card,
    #calcGrid[data-active-panel="discount"] .currency-card,
    #calcGrid[data-active-panel="discount"] .fmcg-mobile-wrapper,
    #calcGrid[data-active-panel="currency"] .right-column,
    #calcGrid[data-active-panel="currency"] .fmcg-mobile-wrapper {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .fmcg-mobile-wrapper {
        display: none !important;
    }

    .desktop-only {
        display: block;
    }
}
