/* Eastmark Quotations - main styles */
:root {
    --eastmark-dark: #001028;
    --eastmark-mid: #5D6975;
    --eastmark-border: #C1CED9;
    --eastmark-bg: #F5F5F5;
    --eastmark-red: #B20000;
    --eastmark-green: #4CAF50;
}

* { box-sizing: border-box; }
body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    color: var(--eastmark-dark);
    background: #fff;
    margin: 0;
    padding: 20px;
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
}

h1 { font-size: 1.5rem; color: var(--eastmark-mid); margin-bottom: 1rem; }
a { color: #004A7F; text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.btn-primary { background: #004A7F; color: #fff; }
.btn-primary:hover { background: #003a60; color: #fff; }
.btn-success { background: var(--eastmark-green); color: #fff; }
.btn-danger { background: var(--eastmark-red); color: #fff; }
.btn-secondary { background: var(--eastmark-mid); color: #fff; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
table.data-table th,
table.data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--eastmark-border); }
table.data-table th { background: var(--eastmark-dark); color: #fff; }
table.data-table tr:nth-child(even) { background: var(--eastmark-bg); }
table.data-table .num { text-align: right; }
table.data-table .col-item {
    width: 180px;
    max-width: 180px;
    overflow-x: auto;
    white-space: nowrap;
    box-sizing: border-box;
}
table.data-table th.actions { text-align: left; }
table.data-table .actions { 
    white-space: nowrap; 
    text-align: right !important;
    width: 180px;
}
.btn-icon {
    display: inline-block;
    position: relative;
    padding: 4px 5px;
    margin: 0 1px;
    text-decoration: none;
    font-size: 18px;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
.btn-icon i {
    display: inline-block;
}

/* Custom tooltips (Bootstrap-like): white text on black, appear 2s after hover, CSS-only */
.btn-icon .tooltip,
table.data-table .btn-icon .tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 6px 10px;
    background-color: #000000;
    background: #000000;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease 0s;
    z-index: 1070;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.btn-icon .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #000;
}
.btn-icon:hover .tooltip {
    opacity: 1;
    transition: opacity 0.15s ease 2s;
}

/* Global styled tooltip (black bg, white text) for title attributes - shown by JS */
#app-styled-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    background: #000;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    z-index: 99999;
    pointer-events: none;
    display: none;
    max-width: 280px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 4px; color: var(--eastmark-mid); font-weight: 600; }
.form-group input,
.form-group textarea,
.form-group select,
.customer-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--eastmark-border);
    border-radius: 4px;
    font-size: 14px;
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-row-terms { grid-template-columns: 1.65fr 1.09fr 1.77fr 0.7fr; min-width: 0; }
.form-row-terms .form-group { min-width: 0; }
.form-row-terms .form-group input[type="text"],
.form-row-terms .form-group select { min-height: 38px; box-sizing: border-box; }

.items-table { width: 100%; border-collapse: collapse; }
.items-table th { background: var(--eastmark-mid); color: #fff; padding: 8px; font-size: 12px; }
.items-table td { padding: 6px 8px; border: 1px solid var(--eastmark-border); }
.items-table input { width: 100%; padding: 4px 6px; border: 1px solid #ddd; }
.items-table { table-layout: auto; width: 100%; }
.items-table th.col-desc { width: auto; min-width: 320px; }
.items-table td.col-desc { width: auto; min-width: 320px; }
.items-table th.col-comment,
.items-table td.col-comment { width: 200px !important; min-width: 200px; vertical-align: top; }
.items-table th.col-comment { white-space: normal; }
.items-table .item-comment { width: 100% !important; box-sizing: border-box; font-size: 12px; color: #555; min-height: 112px; resize: vertical; display: block; padding: 4px 6px; border: 1px solid #ddd; }
.items-table th.col-hs,
.items-table td.col-hs { width: 110px !important; min-width: 110px; }
.items-table th.col-qty,
.items-table td.col-qty { width: 72px !important; min-width: 72px; white-space: nowrap; }
.items-table th.col-unit,
.items-table td.col-unit { width: 82px !important; min-width: 82px; white-space: nowrap; }
.items-table th.col-price,
.items-table td.col-price { width: 110px !important; min-width: 110px; white-space: nowrap; }
.items-table th.col-total,
.items-table td.col-total { width: 110px !important; min-width: 110px; text-align: right; white-space: nowrap; }
.items-table th.col-actions,
.items-table td.col-actions { width: 50px !important; white-space: nowrap; }
.items-table .item-desc { width: 100% !important; box-sizing: border-box; display: block; font-weight: 700; }
.items-table .item-tech { width: 100% !important; box-sizing: border-box; font-size: 12px; color: #666; min-height: 60px; resize: vertical; display: block; }
/* Choices.js in table */
.items-table .col-unit .choices { width: 100%; }
.items-table .col-unit .choices__inner { min-height: 32px; padding: 4px 8px; }

.form-actions-right { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }

/* Toast slide-in/out (used with SweetAlert2) */
.swal2-popup.swal2-slide-toast {
    animation: toastSlideIn 0.4s ease forwards;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #a3d9a5;
    box-shadow: 0 4px 12px rgba(27, 94, 32, 0.15);
}
/* Contrast: darker green success icon on light green background */
.swal2-popup.swal2-slide-toast .swal2-success .swal2-success-ring { border-color: rgba(27, 94, 32, 0.3); }
.swal2-popup.swal2-slide-toast .swal2-success [class^='swal2-success-line'] { border-color: #1b5e20; }
.swal2-popup.swal2-slide-toast .swal2-icon.swal2-success::after { border-color: #1b5e20; }
.swal2-popup.swal2-slide-toast.toast-slide-out { animation: toastSlideOut 0.4s ease forwards !important; }
.swal2-container:has(.swal2-slide-toast) { overflow: visible !important; }

/* Error toast: red background, contrast for error icon */
.swal2-popup.swal2-slide-toast-error {
    animation: toastSlideIn 0.4s ease forwards;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 1px solid #f1aeb5;
    box-shadow: 0 4px 12px rgba(176, 0, 32, 0.15);
}
.swal2-popup.swal2-slide-toast-error .swal2-icon.swal2-error { border-color: #b02a37; }
.swal2-popup.swal2-slide-toast-error .swal2-icon.swal2-error [class^='swal2-x-mark-line'] { background-color: #b02a37; }
.swal2-popup.swal2-slide-toast-error.toast-slide-out { animation: toastSlideOut 0.4s ease forwards !important; }
.swal2-container:has(.swal2-slide-toast-error) { overflow: visible !important; }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ===== Main navigation (Le Pélican-style: fixed bar + hover dropdown) ===== */
.ns-nav {
    --ns-primary-color: #004A7F;
    --ns-text-color: var(--eastmark-dark);
    --ns-dropdown-bg: #fff;
    --ns-hover-bg: var(--eastmark-bg);
    --ns-border-color: var(--eastmark-border);
    --ns-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.ns-nav * { margin: 0; padding: 0; box-sizing: border-box; }
.ns-nav ul { list-style: none; }

.ns-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: #fff;
    box-shadow: var(--ns-shadow);
    height: 88px;
    min-height: 88px;
    overflow: visible;
}
.ns-nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    width: 100%;
    height: 100%;
    position: relative;
}
.ns-navbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--ns-text-color);
    font-weight: 600;
    font-size: 1.05rem;
    gap: 0.5rem;
}
.ns-navbar-brand:hover { color: var(--ns-primary-color); text-decoration: none; }
.ns-navbar-brand img { height: 80px; width: auto; }

.ns-navbar-toggle {
    display: none;
    background: var(--ns-primary-color);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.ns-navbar-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.ns-navbar-nav {
    display: flex;
    flex-direction: row;
    margin: 0;
    padding: 0;
    gap: 0.15rem;
}
.ns-nav-item { position: relative; }
.ns-nav-link {
    color: var(--ns-text-color);
    font-size: 14px;
    padding: 0.5rem 1rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}
.ns-nav-link:hover { color: var(--ns-primary-color); text-decoration: none; }
.ns-nav-link.active { color: var(--ns-primary-color); font-weight: 600; }
.ns-nav-link > .bi:not(.bi-chevron-down) { margin-right: 6px; }
.ns-nav-link.ns-dropdown-toggle { padding-right: 1.5rem; cursor: pointer; }
.ns-nav-link.ns-dropdown-toggle .bi-chevron-down {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    transition: transform 0.2s;
}
.ns-nav-item.ns-dropdown:hover .ns-nav-link.ns-dropdown-toggle .bi-chevron-down {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown: invisible bridge so hover doesn't break between trigger and menu */
.ns-nav-item.ns-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    height: 12px;
    background: transparent;
    pointer-events: auto;
    z-index: 1000;
}
.ns-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 260px;
    width: max-content;
    max-width: 95vw;
    padding: 0.4rem 0;
    margin-top: 5px;
    background: var(--ns-dropdown-bg);
    border: 1px solid var(--ns-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}
.ns-dropdown-menu li {
    white-space: nowrap;
}
.ns-nav-item.ns-dropdown:hover .ns-dropdown-menu,
.ns-nav-item.ns-dropdown .ns-dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
.ns-nav-item.ns-dropdown:last-child .ns-dropdown-menu,
.ns-nav-item.ns-dropdown:nth-last-child(2) .ns-dropdown-menu {
    left: auto;
    right: 0;
}
.ns-dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    color: var(--ns-text-color);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
    white-space: nowrap;
}
.ns-dropdown-item:hover {
    background: var(--ns-hover-bg);
    text-decoration: none;
    color: var(--ns-primary-color);
}
.ns-dropdown-item .bi { margin-right: 8px; font-size: 1em; }
.ns-dropdown-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--eastmark-border, #ddd);
    list-style: none;
}

.ns-navbar-menu .ns-btn-logout {
    margin-left: 1rem;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--eastmark-mid);
    background: transparent;
    color: var(--eastmark-mid);
    cursor: pointer;
    text-decoration: none;
}
.ns-navbar-menu .ns-btn-logout:hover {
    background: var(--eastmark-mid);
    color: #fff;
}

/* Context actions in nav (quotation / proforma view) */
.ns-nav-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--eastmark-border);
}
.ns-nav-action-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: var(--eastmark-mid);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}
.ns-nav-action-link:hover {
    background: var(--eastmark-bg);
    color: var(--eastmark-dark);
}
.ns-nav-action-link .bi {
    font-size: 1.1rem;
}
.ns-nav-action-link[href*="pdf"] .bi { color: var(--eastmark-red); }
.ns-nav-action-link[href*="excel"] .bi { color: var(--eastmark-green); }
.ns-nav-action-link[href*="javascript:window.print"] .bi { color: var(--eastmark-mid); }

/* Mobile */
@media (max-width: 991px) {
    .ns-navbar-toggle { display: flex; }
    .ns-navbar-menu {
        position: fixed;
        top: 88px;
        left: 0;
        right: 0;
        background: #fff;
        z-index: 1029;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        max-height: calc(100vh - 88px);
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        display: none;
        padding: 0.5rem 0;
    }
    .ns-navbar-menu.open { display: flex; }
    .ns-navbar-nav { flex-direction: column; gap: 0; }
    .ns-nav-link {
        padding: 12px 1.25rem;
        justify-content: space-between;
    }
    .ns-dropdown-menu {
        position: static !important;
        display: none;
        width: 100%;
        max-width: none;
        margin-top: 0;
        background: var(--eastmark-bg);
        padding: 0.25rem 0;
        border-left: 4px solid var(--ns-primary-color);
        border-radius: 0;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
        box-shadow: none;
    }
    .ns-dropdown-menu.open { display: block; }
    .ns-dropdown-item { padding: 10px 1.25rem 10px 2rem; }
    .ns-nav-item.ns-dropdown::before { display: none; }
    .ns-nav-actions {
        margin: 0.5rem 1rem 0;
        padding: 0.5rem 0;
        padding-left: 1rem;
        border-left: 4px solid var(--ns-primary-color);
        gap: 6px;
    }
    .ns-nav-action-link span { display: inline; }
    .ns-navbar-menu .ns-btn-logout {
        margin: 0.5rem 1rem 0;
        display: block;
        text-align: center;
    }
}

body.has-fixed-nav { padding-top: 108px; }

.page-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.notice { color: var(--eastmark-mid); font-size: 13px; margin-top: 1rem; }

@media print {
    .no-print { display: none !important; }
}

/* Packing list box dimensions table: center text, grey readonly (e.g. W when cylinder) */
#edit-pl-boxes th {
    white-space: nowrap;
}
#edit-pl-boxes td {
    text-align: center;
}
#edit-pl-boxes input[type="text"],
#edit-pl-boxes input[type="number"],
#edit-pl-boxes select {
    text-align: center !important;
}
#edit-pl-boxes input[readonly] {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* Sliding toast: in from right, stays 3s, slides back out */
.toast-slide {
    position: fixed;
    top: 120px;
    right: 0;
    transform: translateX(100%);
    padding: 14px 20px 14px 16px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-right: none;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 2px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #155724;
    transition: transform 0.35s ease-out;
    max-width: 90vw;
}
.toast-slide.toast-show {
    transform: translateX(0);
}
.toast-slide.toast-hide {
    transform: translateX(100%);
}
.toast-slide .toast-icon {
    font-size: 1.25rem;
    color: #28a745;
    flex-shrink: 0;
}

/* Email confirmation modal (no Bootstrap/jQuery) */
.email-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}
.email-modal-overlay.is-open {
    display: flex;
}
.email-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}
.email-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--eastmark-border, #C1CED9);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--eastmark-dark, #001028);
}
.email-modal-body {
    padding: 20px;
}
.email-modal-body p {
    margin: 0 0 12px 0;
}
.email-modal-body label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--eastmark-mid, #5D6975);
    font-size: 13px;
}
.email-modal-body input,
.email-modal-body textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--eastmark-border, #C1CED9);
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}
.email-modal-body textarea {
    min-height: 80px;
    resize: vertical;
}
.email-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--eastmark-border, #C1CED9);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.email-modal-footer .btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
/* Cancel button: grey border (form and modal) */
.btn-cancel,
.email-modal-footer .btn-cancel {
    background: var(--eastmark-bg, #F5F5F5);
    color: var(--eastmark-dark, #001028);
    border: 1px solid var(--eastmark-border, #C1CED9);
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    font-size: 14px;
}
.btn-cancel:hover,
.email-modal-footer .btn-confirm {
    background: var(--eastmark-red, #B20000);
    color: #fff;
}
.email-modal-footer .btn-confirm:hover {
    background: #9a0000;
}
.email-modal-footer .btn-cancel:hover {
    background: #e8e8e8;
}
