/* TNT CRM — Shared Styles v2026.0317.1 */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px; line-height: 1.5;
    color: #333; background: #f5f7fa;
}
a { color: #0073aa; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== NAVIGATION BAR ===== */
.crm-nav {
    background: #1e3a5f;
    color: #fff;
    position: sticky; top: 0; z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.crm-nav-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex; align-items: center;
    padding: 0 20px;
    height: 50px;
}
.crm-brand {
    margin-right: 30px; white-space: nowrap;
    text-decoration: none; display: flex; align-items: center;
}
.crm-brand:hover { text-decoration: none; opacity: 0.85; }
.crm-brand-logo { height: 28px; width: auto; }
.crm-translate-btn {
    margin-left: auto; background: rgba(255,255,255,0.15); color: #fff;
    border: 1px solid rgba(255,255,255,0.3); border-radius: 4px;
    padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
    white-space: nowrap; transition: background 0.2s;
}
.crm-translate-btn:hover { background: rgba(255,255,255,0.25); }
.crm-logout-btn {
    color: rgba(255,255,255,0.7); font-size: 12px; text-decoration: none;
    padding: 5px 10px; border: 1px solid rgba(255,255,255,0.2); border-radius: 4px;
    margin-left: 8px; white-space: nowrap;
}
.crm-logout-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }
.goog-te-banner-frame, .goog-te-gadget { display: none !important; }
body { top: 0 !important; }
.crm-nav-links {
    list-style: none; margin: 0; padding: 0;
    display: flex; gap: 2px;
}
.crm-nav-links li a {
    color: rgba(255,255,255,0.8);
    padding: 14px 14px;
    display: block; font-size: 13px; font-weight: 500;
    text-decoration: none; transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.crm-nav-links li a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff; text-decoration: none;
}
.crm-nav-links li a.active {
    background: rgba(255,255,255,0.15);
    color: #fff; border-bottom: 2px solid #4fc3f7;
}
/* Dropdown menus */
.crm-dropdown { position: relative; }
.crm-dropdown-toggle { cursor: default !important; }
.crm-caret { font-size: 10px; margin-left: 3px; opacity: 0.6; }
.crm-dropdown-menu {
    display: none; position: absolute; top: 100%; left: 0;
    list-style: none; margin: 0; padding: 4px 0;
    background: #1a3250; min-width: 180px;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 1001;
}
.crm-dropdown-menu li a {
    padding: 10px 18px !important; font-size: 13px !important;
    color: rgba(255,255,255,0.85) !important;
}
.crm-dropdown-menu li a:hover {
    background: rgba(255,255,255,0.12) !important;
    color: #fff !important;
}
.crm-dropdown-menu li a.active {
    background: rgba(255,255,255,0.15) !important;
    color: #fff !important;
    border-bottom: none; border-left: 3px solid #4fc3f7;
}
.crm-dropdown:hover .crm-dropdown-menu { display: block; }
.crm-dropdown.active-group > a { color: #fff !important; border-bottom: 2px solid #4fc3f7; }
.crm-nav-toggle {
    display: none; background: none; border: none;
    color: #fff; font-size: 22px; cursor: pointer;
    margin-left: auto;
}

/* ===== PAGE LAYOUT ===== */
.crm-page {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}
.crm-page-title {
    font-size: 22px; font-weight: 600;
    margin: 0 0 16px 0; color: #1e3a5f;
}

/* ===== TOOLBAR ===== */
.crm-toolbar {
    display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.crm-toolbar .selection-info {
    margin-left: auto;
    font-size: 13px; color: #666;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border: none; border-radius: 5px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; transition: background 0.2s, box-shadow 0.2s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: #0073aa; color: #fff; }
.btn-primary:hover { background: #005a87; }
.btn-success { background: #28a745; color: #fff; }
.btn-success:hover { background: #1e7e34; }
.btn-secondary { background: #e9ecef; color: #333; }
.btn-secondary:hover { background: #dee2e6; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #bd2130; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== TABLE ===== */
.crm-table-wrap {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: auto;
    max-height: calc(100vh - 160px);
    margin-bottom: 20px;
}
.crm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.crm-table thead th {
    background: #0073aa;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* Ensure sticky headers have solid background */
.crm-table thead th::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    border-bottom: 1px solid #005a87;
}
.crm-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
}
.crm-table tbody tr:hover { background: #f0f7ff; }
.crm-table tbody tr.selected { background: #e3f0ff; }
.crm-table tbody td {
    padding: 8px 12px;
    vertical-align: top;
}
.crm-table tbody td.num {
    text-align: right; font-variant-numeric: tabular-nums;
}

/* ===== CSS-ONLY CHECKBOXES (styled divs) ===== */
.css-check {
    width: 20px; height: 20px;
    border: 2px solid #adb5bd;
    border-radius: 4px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    user-select: none;
    flex-shrink: 0;
}
.css-check:hover { border-color: #0073aa; }
.css-check.checked {
    background: #0073aa; border-color: #0073aa;
}
.css-check.checked::after {
    content: '\2713';
    color: #fff; font-size: 14px; font-weight: 700;
    line-height: 1;
}

/* Delivered toggle */
.css-delivered {
    width: 24px; height: 24px;
    border: 2px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
    user-select: none;
}
.css-delivered:hover { border-color: #28a745; }
.css-delivered.checked {
    background: #28a745; border-color: #28a745;
}
.css-delivered.checked::after {
    content: '\2713';
    color: #fff; font-size: 16px; font-weight: 700;
    line-height: 1;
}

/* ===== INLINE EDITING ===== */
.editable {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}
.editable:hover { background: #e8f4fd; }
.inline-edit-input {
    border: 1px solid #0073aa;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 13px;
    outline: none;
    width: 100%;
    max-width: 200px;
}
.inline-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(0,115,170,0.25);
}
select.inline-edit-input {
    max-width: 220px;
}

/* ===== ORDER CONTENT EXPAND ===== */
.order-content-cell { max-width: 250px; }
.order-content-preview { white-space: pre-line; }
.order-content-full { display: none; white-space: pre-line; }
.order-content-cell.expanded .order-content-preview { display: none; }
.order-content-cell.expanded .order-content-full { display: block; }
.expand-toggle {
    color: #0073aa; cursor: pointer;
    font-size: 12px; font-weight: 500;
    display: inline-block; margin-top: 4px;
}
.expand-toggle:hover { text-decoration: underline; }

/* ===== COLLAPSIBLE FORM ===== */
.crm-form-panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.crm-form-panel.collapsed .crm-form-body { display: none; }
.crm-form-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    font-weight: 600; font-size: 15px;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
}
.crm-form-header .toggle-icon { transition: transform 0.2s; }
.crm-form-panel.collapsed .crm-form-header .toggle-icon { transform: rotate(-90deg); }
.crm-form-body {
    padding: 16px;
}
.crm-form-row {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin-bottom: 12px;
}
.crm-form-group {
    flex: 1; min-width: 180px;
}
.crm-form-group label {
    display: block;
    font-size: 12px; font-weight: 600;
    color: #555; margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.crm-form-group input,
.crm-form-group select,
.crm-form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.crm-form-group input:focus,
.crm-form-group select:focus,
.crm-form-group textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
}

/* Autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #ccc;
    border-top: none; border-radius: 0 0 5px 5px;
    max-height: 200px; overflow-y: auto;
    z-index: 100; display: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
    padding: 8px 10px; cursor: pointer;
    font-size: 13px;
}
.autocomplete-item:hover { background: #e8f4fd; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
    padding: 10px 20px;
    border-radius: 6px;
    color: #fff; font-size: 13px; font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 350px;
}
.toast-success { background: #28a745; }
.toast-error { background: #dc3545; }
.toast-info { background: #0073aa; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ===== FAPIAO / FILE UPLOAD ===== */
.fapiao-cell { min-width: 100px; }
.fapiao-total { font-weight: 600; color: #0073aa; }
.fapiao-add { color: #0073aa; cursor: pointer; font-size: 12px; }
.fapiao-upload-icon {
    display: inline-flex; align-items: center;
    cursor: pointer; color: #666; margin-left: 4px;
    font-size: 14px;
}
.fapiao-upload-icon:hover { color: #0073aa; }
.fapiao-files { font-size: 11px; color: #666; margin-top: 2px; }
.fapiao-files a { font-size: 11px; }

/* ===== LOGIN PAGE ===== */
.login-wrap {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: #f5f7fa;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%; max-width: 380px;
}
.login-box h1 {
    text-align: center; color: #1e3a5f;
    margin: 0 0 8px 0; font-size: 24px;
}
.login-box .subtitle {
    text-align: center; color: #888;
    margin: 0 0 24px 0; font-size: 14px;
}
.login-box .form-group {
    margin-bottom: 16px;
}
.login-box label {
    display: block; font-size: 13px; font-weight: 600;
    color: #555; margin-bottom: 4px;
}
.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%; padding: 10px 12px;
    border: 1px solid #ccc; border-radius: 5px;
    font-size: 15px;
}
.login-box input:focus {
    border-color: #0073aa; outline: none;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.15);
}
.login-box .btn { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.login-error {
    background: #ffe0e0; color: #c00;
    padding: 8px 12px; border-radius: 5px;
    font-size: 13px; margin-bottom: 12px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .crm-nav-links { display: none; }
    .crm-nav-toggle { display: block; }
    .crm-nav.open .crm-nav-links {
        display: flex; flex-direction: column;
        position: absolute; top: 50px; left: 0; right: 0;
        background: #1e3a5f;
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        z-index: 1001;
    }
    .crm-nav.open .crm-nav-links li a {
        padding: 12px 20px;
    }
    .crm-dropdown-menu {
        position: static; box-shadow: none;
        background: rgba(0,0,0,0.15); border-radius: 0;
    }
    .crm-dropdown:hover .crm-dropdown-menu,
    .crm-nav.open .crm-dropdown .crm-dropdown-menu { display: block; }
    .crm-dropdown-menu li a { padding-left: 36px !important; }
    .crm-page { padding: 12px; }
    .crm-toolbar { flex-direction: column; align-items: flex-start; }
    .crm-toolbar .selection-info { margin-left: 0; }
}

/* ===== PRINT ===== */
@media print {
    .crm-nav, .crm-toolbar, .crm-form-panel,
    .toast-container, .css-check, .css-delivered,
    .fapiao-upload-icon { display: none !important; }
    .crm-page { padding: 0; max-width: none; }
    .crm-table-wrap { box-shadow: none; border-radius: 0; }
    .crm-table thead th {
        background: #333 !important; color: #fff !important;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    body { background: #fff; }
}
