/* ========================================================
   STARTAI CUSTOMER MANAGEMENT STYLING (MODERN UI)
   ======================================================== */

.startai-customer-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1e293b;
    margin: 20px 0 40px 0;
}

/* Prevent legacy dialog.js from injecting anything at the bottom of the page */
#divDynamicContent {
    display: none !important;
}

/* 1. Search & Filter Bar */
.startai-customer-toolbar {
    margin-bottom: 20px;
}

.startai-search-wrap {
    display: flex;
    align-items: center;
    position: relative;
    max-width: 580px;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.startai-search-wrap:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.startai-search-input {
    flex: 1;
    height: 42px;
    padding: 0 16px;
    border: none;
    outline: none;
    font-size: 14.5px;
    color: #1e293b;
    background: transparent;
}

.startai-search-input::placeholder {
    color: #94a3b8;
}

.startai-search-btn {
    width: 48px;
    height: 42px;
    border: none;
    background: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.startai-search-btn:hover {
    background: #1d4ed8;
}

/* 2. Top Summary Bar & Add Button */
.startai-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding: 0 4px;
}

.startai-top-bar .result-count {
    font-size: 14px;
    color: #475569;
}

.startai-top-bar .result-count b {
    color: #0f172a;
    font-weight: 600;
}

.startai-btn-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    background: #2563eb;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
}

.startai-btn-add:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

/* 3. Customer Data Table */
.startai-table-wrap {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.startai-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.startai-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 14px 16px;
    border-bottom: 1.5px solid #e2e8f0;
}

.startai-table tbody tr.item {
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.startai-table tbody tr.item:hover {
    background-color: #f8fafc;
}

.startai-table tbody tr.item.opened {
    background-color: #eff6ff !important;
}

.startai-table tbody tr.item > td {
    padding: 13px 16px;
    font-size: 13.5px;
    color: #334155;
    vertical-align: middle;
}

/* Specific Columns */
.col-index { width: 55px; text-align: center !important; }
.col-code { width: 125px; }
.col-name { min-width: 200px; }
.col-phone { width: 135px; }
.col-address { min-width: 180px; max-width: 280px; }
.col-orders { width: 100px; text-align: center !important; }
.col-actions { width: 100px; text-align: center !important; }

.badge-index {
    display: inline-block;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

.badge-code {
    display: inline-block;
    padding: 3px 8px;
    background: #e2e8f0;
    color: #334155;
    border-radius: 4px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: monospace;
}

.customer-main-name {
    font-weight: 600;
    color: #0f172a;
}

.customer-sub-company {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.phone-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #0369a1;
    font-size: 13px;
    font-weight: 500;
}

.order-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
}

.order-badge.has-orders {
    background: #dcfce7;
    color: #15803d;
}

/* Action Buttons */
.action-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-action:hover {
    color: #2563eb;
    border-color: #2563eb;
    background: #eff6ff;
}

.btn-action.btn-del-cus:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
}

/* 4. Expandable Details Row */
.startai-table tbody tr.ext {
    display: none;
    background: #f8fafc;
}

.startai-table tbody tr.ext.opened {
    display: table-row;
}

.startai-table tbody tr.ext > td {
    padding: 16px 20px;
    border-bottom: 1.5px solid #e2e8f0;
}

.ext-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 24px;
    font-size: 13px;
}

.ext-details-grid .ext-item {
    display: flex;
    gap: 8px;
}

.ext-details-grid .ext-item.full-width {
    grid-column: 1 / -1;
}

.ext-label {
    font-weight: 600;
    color: #64748b;
    min-width: 90px;
}

.ext-val {
    color: #1e293b;
    word-break: break-word;
}

.ext-val a {
    color: #2563eb;
    text-decoration: none;
}

.ext-val a:hover {
    text-decoration: underline;
}

/* 5. Loading & Empty States */
.startai-loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.startai-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 14px auto;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: startai-spin 0.8s linear infinite;
}

@keyframes startai-spin {
    to { transform: rotate(360deg); }
}

.startai-empty-state {
    text-align: center;
    padding: 50px 20px;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    margin-top: 10px;
}

.startai-empty-state .empty-icon {
    font-size: 40px;
    color: #94a3b8;
    margin-bottom: 12px;
}

.startai-empty-state.access-deny .empty-icon {
    color: #ef4444;
}

.startai-empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 6px 0;
}

.startai-empty-state p {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

/* 6. Simple Paging */
.paging.Customer-paging {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.paging.Customer-paging .page {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.paging.Customer-paging .page:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.paging.Customer-paging .page.currentpage {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

/* ========================================================
   7. STARTAI MODERN MODAL SYSTEM (CENTERED POPUP DIALOG)
   ======================================================== */

.startai-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999999 !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    opacity: 0;
    animation: startaiFadeIn 0.2s ease forwards;
}

@keyframes startaiFadeIn {
    to { opacity: 1; }
}

.startai-modal-dialog {
    background: #ffffff !important;
    border-radius: 16px !important;
    width: 100% !important;
    max-width: 680px !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden !important;
    transform: scale(0.95) translateY(12px);
    animation: startaiScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes startaiScaleIn {
    to { transform: scale(1) translateY(0); }
}

.startai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.startai-modal-header .modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.startai-modal-header .modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}

.startai-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
}

.startai-modal-header .modal-subtitle {
    margin: 3px 0 0 0;
    font-size: 12.5px;
    color: #64748b;
}

.startai-modal-header .btn-close-modal {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.startai-modal-header .btn-close-modal:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.startai-modal-body {
    padding: 22px 24px;
    overflow-y: auto;
    flex: 1;
    box-sizing: border-box;
}

.startai-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

/* Form Sections and Layout */
.startai-form-section {
    margin-bottom: 22px;
}

.startai-form-section:last-child {
    margin-bottom: 0;
}

.startai-form-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #2563eb;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.startai-form-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.startai-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.startai-form-group {
    display: flex;
    flex-direction: column;
}

.startai-form-group.full-width {
    grid-column: 1 / -1;
}

.startai-form-label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.startai-form-label .req {
    color: #ef4444;
    margin-left: 3px;
    font-weight: bold;
}

.startai-form-control {
    width: 100%;
    box-sizing: border-box;
    height: 42px;
    padding: 0 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13.5px;
    color: #1e293b;
    background: #ffffff;
    outline: none;
    transition: all 0.15s ease;
}

.startai-form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.startai-form-control::placeholder {
    color: #94a3b8;
}

textarea.startai-form-control {
    height: auto;
    padding: 10px 14px;
    min-height: 76px;
    resize: vertical;
    font-family: inherit;
}

.startai-form-control.is-invalid {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.startai-modal-footer .btn-cancel {
    padding: 9px 18px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.startai-modal-footer .btn-cancel:hover {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #94a3b8;
}

.startai-modal-footer .btn-save {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 22px;
    background: #2563eb;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
    transition: all 0.15s;
}

.startai-modal-footer .btn-save:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.startai-modal-footer .btn-save:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .startai-form-grid {
        grid-template-columns: 1fr;
    }
    .startai-modal-dialog {
        max-height: 95vh;
    }
}
