/* ============================================
   TABLE STYLES
   ============================================ */

.table-container {
    padding: 0.25rem 1px;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    color: var(--text-secondary);
}

.table-title strong {
    color: var(--text-primary);
}

.table-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.row-counter {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.row-counter span {
    color: var(--accent-orange);
    font-weight: 600;
}

/* Excel Wrapper */
.excel-wrapper {
    background: var(--bg-secondary);
    border-radius: 2px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.excel-scroll {
    overflow: overlay;
    max-height: calc(100vh - 340px);
}

/* Excel Table */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 2400px;
}

.excel-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-table th {
    background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border-color);
    padding: 0.7rem 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.excel-table th:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.excel-table th.selected,
.excel-table th.col-selected {
    background: var(--accent-orange);
    color: white;
}

/* Column cell selection */
.excel-table td.col-selected {
    background: rgba(249, 115, 22, 0.1) !important;
    box-shadow: inset 0 2px 0 0 var(--accent-orange), inset 0 -2px 0 0 var(--accent-orange);
}

/* Row Number Column */
.excel-table th:first-child,
.excel-table td:first-child {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-weight: 600;
    width: 36px;
    min-width: 36px;
    text-align: center;
    cursor: grab;
    user-select: none;
    position: sticky;
    left: 0;
    z-index: 5;
    font-size: 12px;
}

.excel-table td:first-child:hover {
    background: var(--accent-orange);
    color: white;
}

.excel-table td:first-child.dragging {
    cursor: grabbing;
    background: var(--accent-blue);
    color: white;
}

/* Table Cells */
.excel-table td {
    border: 1px solid #e2e8f0;
    padding: 0.3rem 0;
    background: var(--row-white);
    transition: background 0.15s;
}

.excel-table tbody tr:nth-child(even) td:not(:first-child) {
    background: var(--row-alt);
}

.excel-table tbody tr.selected td {
    background: rgba(147, 197, 253, 0.15) !important;
}

.excel-table tbody tr.drag-over {
    border-top: 3px solid var(--accent-orange);
}

.excel-table tbody tr.dragging {
    opacity: 0.5;
}

/* Table Inputs */
.excel-table input {
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    text-align: center;
}

.excel-table input::placeholder {
    color: #94a3b8;
    opacity: 0.4;
}

.excel-table td.selected-cell {
    box-shadow: inset 0 0 0 2px var(--accent-blue);
}

/* Status Cell */
.status-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-badge .status-icon {
    font-size: 0.8rem;
}

/* Status Colors — one unique color per status */
.status-new              { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }  /* violet    */
.status-in-transit       { background: rgba(99, 102, 241, 0.15); color: #4f46e5; }  /* indigo    */
.status-unload-pending   { background: rgba(245, 158, 11, 0.15); color: #b45309; }  /* amber     */
.status-unload-approved  { background: rgba(16, 185, 129, 0.15); color: #059669; }  /* emerald   */
.status-unload-rejected  { background: rgba(239, 68, 68, 0.15);  color: #dc2626; }  /* red       */
.status-arrived          { background: rgba(59, 130, 246, 0.15); color: #2563eb; }  /* blue      */
.status-checked-in       { background: rgba(59, 130, 246, 0.15); color: #2563eb; }  /* blue      */
.status-in-stock         { background: rgba(34, 197, 94, 0.15);  color: #16a34a; }  /* green     */
.status-released         { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */
.status-dispatched       { background: rgba(13, 148, 136, 0.15); color: #0d9488; }  /* teal      */
.status-archived         { background: rgba(107, 114, 128, 0.15); color: #6b7280; } /* gray      */
.status-compliance-blocked { background: rgba(239, 68, 68, 0.15); color: #dc2626; } /* red       */
/* Legacy aliases */
.status-on-hold          { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.status-blocked          { background: rgba(239, 68, 68, 0.15);  color: #dc2626; }
.status-in-process       { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
.status-needs-action     { background: rgba(245, 158, 11, 0.15); color: #b45309; }
/* Cleared but still in transit — green to differentiate */
.status-cleared-transit  { background: rgba(34, 197, 94, 0.15);  color: #16a34a; }  /* green     */
/* Stock-specific statuses */
.status-in-order         { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */
.status-picked           { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }  /* violet    */
.status-allocated        { background: rgba(14, 165, 233, 0.15); color: #0284c7; }  /* sky       */

/* Column Widths */
.col-status { width: 115px; min-width: 115px; }
.col-notes { width: 85px; min-width: 85px; }
.col-file { width: 90px; min-width: 90px; }
.col-customer { width: 130px; min-width: 130px; }
.col-shipper { width: 200px; min-width: 200px; }
.col-container { width: 120px; min-width: 120px; }
.col-vessel { width: 130px; min-width: 130px; }
.col-cia { width: 75px; min-width: 75px; }
.col-terminal { width: 85px; min-width: 85px; }
.col-whs { width: 75px; min-width: 75px; }
.col-freight { width: 80px; min-width: 80px; }
.col-release { width: 80px; min-width: 80px; }
.col-qc { width: 60px; min-width: 60px; }
.col-phyto { width: 70px; min-width: 70px; }
.col-t1 { width: 80px; min-width: 80px; }
.col-kcb { width: 80px; min-width: 80px; }
.col-customs { width: 65px; min-width: 65px; }
.col-planned { width: 68px; min-width: 68px; }
.col-arrived { width: 68px; min-width: 68px; }
.col-carrier { width: 90px; min-width: 90px; }

/* Dashboard panes */
.dashboard-pane {
    display: none;
}

.dashboard-pane.active {
    display: block;
}

/* Re-export board */
.table-container.reexport-pane {
    padding-left: 1px;
    padding-right: 1px;
}

.reexport-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
}

.reexport-pane .excel-wrapper {
    background: #f7faf2;
    border-color: #cfd9bf;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.reexport-help,
.reexport-empty,
.crossdock-placeholder {
    border-radius: 8px;
}

.reexport-help {
    margin-bottom: 0.9rem;
    padding: 0.85rem 1rem;
    border: 1px solid #cdddbb;
    background: #eef6e6;
    color: #29403c;
    font-size: 0.78rem;
    line-height: 1.5;
}

.reexport-empty,
.crossdock-placeholder {
    padding: 1.4rem;
    border: 1px dashed var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-align: center;
}

.crossdock-placeholder strong {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.reexport-scroll {
    max-height: calc(100vh - 330px);
}

.reexport-table {
    width: 100%;
}

.reexport-table th {
    background: linear-gradient(180deg, #dae8c9 0%, #edf6e4 100%);
    border-color: #c6d7af;
    color: #243527;
}

.reexport-table td {
    border-color: #d4ddc8;
    background: #eff7e5;
    vertical-align: middle;
}

.reexport-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #e4f0d7;
}

.reexport-table tbody tr:hover td {
    background: #d9ecc6;
}

.reexport-table th:first-child,
.reexport-table td:first-child {
    position: static;
    left: auto;
    width: 120px;
    min-width: 120px;
    cursor: default;
    color: inherit;
    background: inherit;
}

.reexport-table td:first-child:hover,
.reexport-table td:first-child.dragging {
    background: inherit;
    color: inherit;
}

.reexport-table th:hover {
    background: #d2e2bf;
    color: #1d2b20;
}

.reexport-table .status-badge {
    font-size: 0.7rem;
}

.reexport-head-main {
    font-size: 12px;
    line-height: 1.3;
}

.reexport-head-sub {
    font-size: 10px;
    line-height: 1.3;
    text-transform: none;
    color: #5b6d5f;
    font-weight: 500;
}

.reexport-readonly {
    padding: 0.45rem 0.55rem;
    text-align: center;
    color: #1f2937;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.reexport-col-customer,
.reexport-col-shipper,
.reexport-col-vessel {
    font-family: 'Space Grotesk', sans-serif;
}

.reexport-table input,
.reexport-table select {
    width: 100%;
    padding: 0.42rem 0.45rem;
    border: none;
    background: transparent;
    color: #1f2937;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    outline: none;
    text-align: center;
}

.reexport-table select {
    cursor: pointer;
}

.reexport-date-time {
    display: grid;
    grid-template-columns: minmax(55px, 1fr) 70px;
    align-items: center;
}

.reexport-date-time input + input {
    border-left: 1px solid #d4ddc8;
}

.reexport-action-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.4rem 0.45rem;
    color: #1f2937;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
}

.reexport-action-toggle input {
    width: auto;
    margin: 0;
}

.reexport-row-focus td {
    box-shadow: inset 0 0 0 2px #16a34a;
}

.reexport-row-archiving td {
    background: #86efac !important;
    transition: background 0.2s ease;
}

.reexport-source-missing td {
    opacity: 0.7;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

.reexport-col-status-source { min-width: 110px; }
.reexport-col-notes { min-width: 110px; }
.reexport-col-file { min-width: 85px; }
.reexport-col-customer { min-width: 130px; }
.reexport-col-shipper { min-width: 180px; }
.reexport-col-cargo { min-width: 135px; }
.reexport-col-vessel { min-width: 140px; }
.reexport-col-whs { min-width: 90px; }
.reexport-col-docs { min-width: 140px; }
.reexport-col-workflow { min-width: 100px; }
.reexport-col-label { min-width: 80px; }
.reexport-col-qc { min-width: 70px; }
.reexport-col-weight { min-width: 100px; }
.reexport-col-invoice { min-width: 110px; }
.reexport-col-phyto { min-width: 80px; }
.reexport-col-cvo { min-width: 85px; }
.reexport-col-transport { min-width: 110px; }
.reexport-col-fullset { min-width: 75px; }
.reexport-col-loading { min-width: 125px; }
.reexport-col-deadline { min-width: 140px; }
.reexport-col-slot { min-width: 140px; }
.reexport-col-action { min-width: 95px; }

/* ============================================
   LIGHT THEME - TABLE STYLING
   ============================================ */

[data-theme="light"] .table-container {
    background: transparent !important;
}

[data-theme="light"] .table-title {
    color: #64748b !important;
}

[data-theme="light"] .table-title strong {
    color: #0f172a !important;
}

[data-theme="light"] .row-counter {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #64748b !important;
}

[data-theme="light"] .row-counter span {
    color: #475569 !important;
}

[data-theme="light"] .excel-wrapper {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08) !important;
}

/* Table Headers - Light Theme */
[data-theme="light"] .excel-table th {
    background: linear-gradient(180deg, #e2e8f0 0%, #f1f5f9 100%) !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light"] .excel-table th:hover {
    background: #cbd5e1 !important;
    color: #0f172a !important;
}

[data-theme="light"] .excel-table th.selected,
[data-theme="light"] .excel-table th.col-selected {
    background: #475569 !important;
    color: #ffffff !important;
}

/* Column cell selection - Light Theme */
[data-theme="light"] .excel-table td.col-selected {
    background: rgba(71, 85, 105, 0.1) !important;
    box-shadow: inset 0 2px 0 0 #475569, inset 0 -2px 0 0 #475569 !important;
}

/* Row Number Column - Light Theme */
[data-theme="light"] .excel-table th:first-child,
[data-theme="light"] .excel-table td:first-child {
    background: #e2e8f0 !important;
    color: #475569 !important;
    border-color: #cbd5e1 !important;
}

[data-theme="light"] .excel-table td:first-child:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .excel-table td:first-child.dragging {
    background: #475569 !important;
    color: #ffffff !important;
}

/* Table Cells - Light Theme */
[data-theme="light"] .excel-table td {
    border-color: #e2e8f0 !important;
    background: #ffffff !important;
}

[data-theme="light"] .excel-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #f8fafc !important;
}

[data-theme="light"] .excel-table tbody tr.selected td {
    background: rgba(71, 85, 105, 0.1) !important;
}

[data-theme="light"] .excel-table tbody tr.drag-over {
    border-top-color: #475569 !important;
}

/* Table Inputs - Light Theme */
[data-theme="light"] .excel-table input {
    color: #0f172a !important;
}

[data-theme="light"] .excel-table input::placeholder {
    color: #94a3b8 !important;
}

[data-theme="light"] .excel-table td.selected-cell {
    box-shadow: inset 0 0 0 2px #475569 !important;
}

[data-theme="light"] .reexport-pane .excel-wrapper {
    background: #f7faf2 !important;
    border-color: #cfd9bf !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .reexport-table th {
    background: linear-gradient(180deg, #dae8c9 0%, #edf6e4 100%) !important;
    border-color: #c6d7af !important;
    color: #243527 !important;
}

[data-theme="light"] .reexport-table th:hover {
    background: #d2e2bf !important;
    color: #1d2b20 !important;
}

[data-theme="light"] .reexport-table td {
    background: #eff7e5 !important;
    border-color: #d4ddc8 !important;
}

[data-theme="light"] .reexport-table tbody tr:nth-child(even) td:not(:first-child) {
    background: #e4f0d7 !important;
}

[data-theme="light"] .reexport-table tbody tr:hover td {
    background: #d9ecc6 !important;
}

[data-theme="light"] .reexport-table th:first-child,
[data-theme="light"] .reexport-table td:first-child {
    background: inherit !important;
    color: inherit !important;
}

[data-theme="light"] .reexport-table td:first-child:hover,
[data-theme="light"] .reexport-table td:first-child.dragging {
    background: inherit !important;
    color: inherit !important;
}

[data-theme="light"] .reexport-help {
    background: #eef6e6 !important;
    border-color: #cdddbb !important;
    color: #29403c !important;
}

/* ============================================
   MINI CALENDAR DATE PICKER
   ============================================ */

.mini-calendar-overlay {
    position: fixed;
    z-index: 9999;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    padding: 10px;
    width: 220px;
    display: none;
    font-family: 'Space Grotesk', 'JetBrains Mono', sans-serif;
    font-size: 12px;
}

.mini-calendar-overlay.visible {
    display: block;
}

.mini-cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mini-cal-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #f1f5f9);
}

.mini-cal-nav {
    background: none;
    border: 1px solid var(--border-color, #334155);
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.15s;
}

.mini-cal-nav:hover {
    background: var(--bg-hover, #334155);
    color: var(--text-primary, #f1f5f9);
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-cal-day-header {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    padding: 4px 0;
    text-transform: uppercase;
}

.mini-cal-cell {
    text-align: center;
    padding: 5px 2px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary, #cbd5e1);
    transition: all 0.1s;
    font-size: 11px;
}

.mini-cal-cell:hover {
    background: var(--accent-orange, #f97316);
    color: white;
}

.mini-cal-cell.today {
    background: rgba(59, 130, 246, 0.25);
    color: #60a5fa;
    font-weight: 700;
}

.mini-cal-cell.today:hover {
    background: var(--accent-orange, #f97316);
    color: white;
}

.mini-cal-cell.empty {
    cursor: default;
}

.mini-cal-cell.empty:hover {
    background: none;
}

.mini-cal-footer {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color, #334155);
    padding-top: 8px;
}

.mini-cal-footer button {
    flex: 1;
    padding: 5px 0;
    border: 1px solid var(--border-color, #334155);
    border-radius: 4px;
    background: var(--bg-tertiary, #0f172a);
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s;
}

.mini-cal-footer button:hover {
    background: var(--bg-hover, #334155);
    color: var(--text-primary, #f1f5f9);
}

/* Mini Calendar - Light Theme */
[data-theme="light"] .mini-calendar-overlay {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12) !important;
}

[data-theme="light"] .mini-cal-title {
    color: #0f172a !important;
}

[data-theme="light"] .mini-cal-nav {
    border-color: #cbd5e1 !important;
    color: #64748b !important;
}

[data-theme="light"] .mini-cal-nav:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

[data-theme="light"] .mini-cal-cell {
    color: #334155 !important;
}

[data-theme="light"] .mini-cal-cell:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .mini-cal-cell.today {
    background: rgba(59, 130, 246, 0.15) !important;
    color: #2563eb !important;
}

[data-theme="light"] .mini-cal-cell.today:hover {
    background: #475569 !important;
    color: #ffffff !important;
}

[data-theme="light"] .mini-cal-footer button {
    background: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #475569 !important;
}

[data-theme="light"] .mini-cal-footer button:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
