/* ==========================================================
   FILE: partial-payment.css
   PREMIUM SOBER ERP LOOK
   Compatible With Existing partial-payment.html
========================================================== */

:root {
    --primary: #108082;
    --primary-dark: #0b6466;
    --primary-soft: #eaf7f7;

    --green: #16a34a;
    --green-dark: #0f7a35;
    --green-soft: #eafaf0;

    --orange: #f97316;
    --orange-dark: #c2410c;
    --orange-soft: #fff4e8;

    --purple: #7c3aed;
    --purple-dark: #5b21b6;
    --purple-soft: #f4f0ff;

    --red: #dc2626;
    --red-soft: #fff0f0;

    --bg: #f5f7fa;
    --card: #ffffff;
    --border: #e5e7eb;
    --border-dark: #d1d5db;
    --text: #111827;
    --muted: #6b7280;

    --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 28px 70px rgba(15, 23, 42, 0.22);

    --radius: 16px;
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.main-content {
    padding: 24px;
    width: 100%;
}

/* TOPBAR */
.topbar {
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary);
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 25px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
}

.topbar p {
    font-size: 14px;
    color: var(--muted);
}

/* SECTION */
.section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-md);
}

.section-card h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-card h2 i {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* TABLE */
.table-wrap {
    margin-top: 18px;
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
}

.table-wrap::-webkit-scrollbar {
    height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1050px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #374151;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    text-align: left;
    padding: 14px 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 13px;
    border-bottom: 1px solid #edf0f4;
    font-size: 13px;
    color: #374151;
    vertical-align: middle;
    background: #fff;
    white-space: nowrap;
}

tbody tr:hover td {
    background: #fbfefe;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody td:first-child {
    font-weight: 800;
    color: var(--primary-dark);
}

/* EMPTY / ERROR */
.table-empty,
.table-error {
    text-align: center !important;
    padding: 32px !important;
    font-size: 14px !important;
}

.table-empty {
    color: var(--muted) !important;
}

.table-error {
    color: var(--red) !important;
    background: var(--red-soft) !important;
}

/* AMOUNTS */
.amount-text {
    font-weight: 800;
    font-size: 13px;
}

.amount-text.received {
    color: #047857;
}

.amount-text.pending {
    color: var(--orange-dark);
}

/* MINI PROGRESS */
.mini-progress {
    margin-top: 7px;
    min-width: 120px;
}

.mini-progress-top {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 4px;
}

.mini-progress-track {
    height: 6px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--green));
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* BUTTONS */
.btn {
    border: none;
    outline: none;
    cursor: pointer;
    padding: 9px 13px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    white-space: nowrap;
    transition: 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.success {
    background: var(--green);
    color: #fff;
}

.btn.success:hover {
    background: var(--green-dark);
}

.btn.secondary {
    background: #eef2f7;
    color: #374151;
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: #e5e7eb;
}

.btn.special-req-btn {
    background: var(--purple);
    color: #fff;
}

.btn.special-req-btn:hover {
    background: var(--purple-dark);
}

.btn.special-req-btn.sent {
    background: #0f766e;
    color: #fff;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: nowrap;
}

/* BADGES */
.badge {
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.badge.partial {
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #bae6fd;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.badge.confirmed {
    background: var(--green-soft);
    color: #166534;
}

.badge.cancelled {
    background: var(--red-soft);
    color: #991b1b;
}

.badge.hold {
    background: #f3f4f6;
    color: #374151;
}

/* FOOTER */
.footer {
    margin-top: 28px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* COMMON MODALS */
#partialPaymentModal,
.unlock-modal,
#specialRequestModal,
.special-view-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(5px);
}

#partialPaymentModal.show,
.unlock-modal.show,
#specialRequestModal.show,
.special-view-modal.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

#partialPaymentModal {
    z-index: 10000;
}

#specialRequestModal {
    z-index: 10010;
}

.unlock-modal {
    z-index: 10020;
}

.special-view-modal {
    z-index: 10030;
}

/* PARTIAL PAYMENT MODAL */
.partial-modal-box {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: popIn 0.22s ease;
}

.partial-modal-head {
    padding: 18px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.partial-modal-head h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.partial-modal-head h2 i {
    color: var(--green);
}

.partial-close-btn,
.unlock-close,
.special-close-btn,
#specialRequestModal .reason-head button {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #eef2f7;
    color: #374151;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.partial-close-btn:hover,
.unlock-close:hover,
.special-close-btn:hover,
#specialRequestModal .reason-head button:hover {
    background: #e5e7eb;
}

.partial-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.partial-summary-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.partial-info-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 15px;
    background: #f8fafc;
}

.partial-info-card.grand-card {
    background: var(--green-soft);
    border-color: #bbf7d0;
}

.partial-info-card.pending-card {
    background: var(--orange-soft);
    border-color: #fed7aa;
}

.partial-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 7px;
}

.partial-value {
    font-size: 20px;
    font-weight: 900;
    color: var(--text);
}

.grand-card .partial-value {
    color: #047857;
}

.pending-card .partial-value {
    color: var(--orange-dark);
}

.partial-input-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.partial-input-group label {
    font-size: 12px;
    font-weight: 800;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 7px;
}

#receivedAmountInput {
    width: 100%;
    height: 50px;
    border: 1.5px solid var(--border-dark);
    border-radius: 12px;
    padding: 0 14px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    outline: none;
    transition: 0.18s ease;
}

#receivedAmountInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(16, 128, 130, 0.12);
}

#receivedAmountInput::placeholder {
    color: #9ca3af;
    font-weight: 500;
}

.partial-progress-wrap {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}

.partial-progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.progress-bar-bg {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--green));
    border-radius: 999px;
    transition: width 0.3s ease;
}

.partial-modal-footer {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* UNLOCK MODAL */
.unlock-box {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.22s ease;
}

.unlock-head {
    padding: 17px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.unlock-head h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.unlock-head h2 i {
    color: var(--orange);
}

.unlock-body {
    padding: 20px;
}

.unlock-body p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 12px;
}

.unlock-input {
    width: 100%;
    height: 46px;
    border: 1.5px solid var(--border-dark);
    border-radius: 11px;
    padding: 0 13px;
    font-size: 15px;
    outline: none;
    transition: 0.18s ease;
}

.unlock-input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
}

.unlock-footer {
    padding: 15px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* SPECIAL REQUEST MODAL */
#specialRequestModal .reason-modal {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.22s ease;
}

#specialRequestModal .reason-head {
    padding: 17px 20px;
    background: #faf8ff;
    border-bottom: 1px solid #ede9fe;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#specialRequestModal .reason-head h2 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 9px;
}

#specialOrderInfo {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    padding: 12px !important;
    background: var(--purple-soft) !important;
    border: 1px solid #ede9fe !important;
    border-radius: 12px !important;
    margin: 16px 20px !important;
    font-size: 13px !important;
}

#specialOrderInfo span {
    background: #fff;
    border: 1px solid #ede9fe;
    border-radius: 999px;
    padding: 7px 10px;
}

#specialOrderInfo b {
    color: var(--purple);
}

#specialRequestModal .reason-modal > div:not(.reason-head):not(#specialOrderInfo) {
    margin-left: 20px;
    margin-right: 20px;
}

#specialRequestModal label {
    display: block;
    font-size: 12px !important;
    font-weight: 800 !important;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

#specialRequestType,
#specialRemarkInput {
    width: 100% !important;
    border: 1.5px solid var(--border-dark) !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: 0.18s ease;
}

#specialRequestType {
    height: 45px;
    padding: 0 12px !important;
}

#specialRemarkInput {
    min-height: 105px;
    padding: 11px 12px !important;
    resize: vertical;
    line-height: 1.45;
}

#specialRequestType:focus,
#specialRemarkInput:focus {
    border-color: var(--purple) !important;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

#specialTypeError,
#specialRemarkError {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    font-weight: 700;
}

#specialRequestModal .reason-modal > div:last-child {
    margin: 0 !important;
    padding: 16px 20px 20px;
    background: #faf8ff;
    border-top: 1px solid #ede9fe;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* SPECIAL VIEW */
.special-view-box {
    width: 100%;
    max-width: 850px;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.22s ease;
}

.special-view-header {
    padding: 22px 24px;
    background: #faf8ff;
    border-bottom: 1px solid #ede9fe;
    display: grid;
    grid-template-columns: 62px 1fr 42px;
    gap: 14px;
    align-items: center;
}

.special-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: #ede9fe;
    color: var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.special-view-header h2 {
    font-size: 23px;
    font-weight: 900;
    color: var(--text);
}

.special-view-header p {
    font-size: 14px;
    color: var(--muted);
    margin-top: 4px;
}

.special-view-body {
    padding: 22px;
}

.special-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
}

.special-card {
    background: #fbfaff;
    border: 1px solid #ede9fe;
    border-radius: 14px;
    padding: 14px 15px;
}

.special-card.full-width {
    grid-column: 1 / -1;
}

.special-label {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--purple);
    margin-bottom: 6px;
}

.special-value {
    font-size: 14px;
    font-weight: 800;
    color: #1e1b4b;
    line-height: 1.45;
    word-break: break-word;
}

.special-view-footer {
    padding: 17px 22px;
    background: #faf8ff;
    border-top: 1px solid #ede9fe;
    text-align: center;
}

.special-ok-btn {
    background: var(--purple);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 34px;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.special-ok-btn:hover {
    background: var(--purple-dark);
}

/* SUCCESS POPUP */
#confirmSuccessPopup {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 18px;
    animation: fadeIn 0.2s ease;
}

.confirm-popup-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.22s ease;
}

.confirm-popup-icon {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    background: var(--green-soft);
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 14px;
}

.confirm-popup-card h2 {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 8px;
}

.confirm-popup-card p {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.45;
    margin-bottom: 20px;
}

.confirm-popup-btn {
    border: none;
    border-radius: 11px;
    background: var(--primary);
    color: #fff;
    padding: 11px 28px;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.confirm-popup-btn:hover {
    background: var(--primary-dark);
}

/* UTILITY */
.mt-2 {
    margin-top: 8px;
}

/* ANIMATION */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* RESPONSIVE */
@media (max-width: 992px) {
    .main-content {
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar .btn {
        width: 100%;
    }

    .section-card {
        padding: 18px;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 14px;
    }

    .topbar {
        padding: 18px;
        border-radius: 14px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .section-card {
        padding: 15px;
        border-radius: 14px;
    }

    table {
        min-width: 980px;
    }

    .partial-summary-row {
        grid-template-columns: 1fr;
    }

    .partial-modal-footer,
    .unlock-footer,
    #specialRequestModal .reason-modal > div:last-child {
        flex-direction: column;
    }

    .partial-modal-footer .btn,
    .unlock-footer .btn,
    #specialRequestModal .reason-modal > div:last-child .btn {
        width: 100%;
    }

    .special-view-header {
        grid-template-columns: 52px 1fr 38px;
        padding: 18px;
    }

    .special-icon {
        width: 50px;
        height: 50px;
        border-radius: 14px;
    }

    .special-view-header h2 {
        font-size: 19px;
    }

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

    #specialOrderInfo span {
        width: 100%;
    }
}

@media (max-width: 520px) {
    #partialPaymentModal,
    .unlock-modal,
    #specialRequestModal,
    .special-view-modal {
        padding: 10px;
    }

    .partial-modal-box,
    .unlock-box,
    #specialRequestModal .reason-modal,
    .special-view-box {
        border-radius: 15px;
    }

    .btn {
        font-size: 11px;
        padding: 8px 10px;
    }
}