/* ==========================================================================
Redwave Order Sheet Sync - Modern Design System
========================================================================== */

:root {
--bg-dark: #080a0d;
--bg-surface: #0f1319;
--bg-surface-elevated: #161b22;
--bg-surface-hover: #1f2631;

--border-subtle: #1e2530;
--border-strong: #2d3748;
--border-focus: #2fd9c4;

--text-main: #f1f5f9;
--text-muted: #8e9aab;
--text-dim: #505c6e;

--accent-teal: #2fd9c4;
--accent-teal-glow: rgba(47, 217, 196, 0.15);
--accent-teal-dark: #072a26;

--accent-purple: #7360f2;
--accent-purple-glow: rgba(115, 96, 242, 0.15);

--status-warning: #fbbf24;
--status-warning-glow: rgba(251, 191, 36, 0.15);

--status-danger: #f87171;
--status-danger-glow: rgba(248, 113, 113, 0.15);

--status-duplicate: #94a3b8;

--font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
--font-mono: 'JetBrains Mono', monospace;

--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 16px;
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
--shadow-glow: 0 0 20px rgba(47, 217, 196, 0.12);

--transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

html {
scroll-behavior: smooth;
color-scheme: dark;
}

body {
background-color: var(--bg-dark);
color: var(--text-main);
font-family: var(--font-sans);
font-size: 14px;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
min-height: 100vh;
display: flex;
flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:focus-visible {
  outline: 2px solid var(--accent-teal);
  outline-offset: 2px;
}

/* Page Loader */
#page-loader {
position: fixed;
inset: 0;
background: var(--bg-dark);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
transition: opacity 0.4s ease, visibility 0.4s ease;
}

#page-loader.fade-out {
opacity: 0;
visibility: hidden;
pointer-events: none;
}

.loader-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}

.loader-bars {
display: flex;
align-items: flex-end;
gap: 6px;
height: 36px;
}

.loader-bars span {
width: 7px;
background: var(--accent-teal);
border-radius: 2px;
transform-origin: bottom;
animation: bar-grow 1s ease-in-out infinite;
}

.loader-bars span:nth-child(1) { height: 40%; animation-delay: 0s; }
.loader-bars span:nth-child(2) { height: 70%; animation-delay: 0.15s; }
.loader-bars span:nth-child(3) { height: 100%; animation-delay: 0.3s; }
.loader-bars span:nth-child(4) { height: 55%; animation-delay: 0.45s; }

@keyframes bar-grow {
0%, 100% { transform: scaleY(0.45); opacity: 0.55; }
50% { transform: scaleY(1); opacity: 1; }
}

.loader-text {
font-size: 13px;
font-weight: 500;
color: var(--text-muted);
letter-spacing: 0.02em;
}

/* Drag and Drop Overlay */
#drop-overlay {
position: fixed;
inset: 0;
background: rgba(8, 10, 13, 0.85);
backdrop-filter: blur(8px);
z-index: 1500;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: var(--transition);
}

#drop-overlay.active {
opacity: 1;
visibility: visible;
}

.drop-overlay-card {
position: absolute;
inset: 28px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
background: var(--bg-surface-elevated);
border: 3px dashed var(--accent-teal);
border-radius: var(--radius-lg);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), var(--shadow-glow);
transform: scale(0.98);
transition: transform 0.2s ease;
}

#drop-overlay.active .drop-overlay-card {
transform: scale(1);
}

.drop-icon-wrapper {
width: 64px;
height: 64px;
border-radius: 50%;
background: var(--accent-teal-glow);
color: var(--accent-teal);
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 16px;
}

.drop-overlay-card h3 {
font-size: 20px;
font-weight: 700;
color: var(--text-main);
margin-bottom: 6px;
}

.drop-overlay-card p {
color: var(--text-muted);
font-size: 14px;
}

/* Application Header */
.app-header {
background: var(--bg-surface);
border-bottom: 1px solid var(--border-subtle);
position: sticky;
top: 0;
z-index: 100;
}

.header-container {
max-width: 1520px;
margin: 0 auto;
padding: 16px 32px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
flex-wrap: wrap;
}

.brand {
display: flex;
align-items: center;
gap: 14px;
}

.brand-logo {
flex-shrink: 0;
width: 42px;
height: 42px;
background: linear-gradient(135deg, var(--bg-surface-elevated), #1e2632);
border: 1px solid var(--border-strong);
border-radius: var(--radius-md);
display: flex;
align-items: center;
justify-content: center;
color: var(--accent-teal);
box-shadow: var(--shadow-sm);
}

.brand-title-wrap {
display: flex;
align-items: center;
gap: 10px;
}

.brand-title-wrap h1 {
font-size: 18px;
font-weight: 700;
letter-spacing: -0.01em;
color: var(--text-main);
}

.subtitle {
font-size: 12.5px;
color: var(--text-muted);
margin-top: 2px;
}

/* Status Badges */
.badge {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 3px 8px;
border-radius: 20px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
}

.badge-online {
background: var(--accent-teal-glow);
color: var(--accent-teal);
border: 1px solid rgba(47, 217, 196, 0.3);
}

.badge-online .dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent-teal);
box-shadow: 0 0 8px var(--accent-teal);
}

/* Mode Selector Segmented Control */
.mode-control-group {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}

.control-label {
font-size: 12px;
font-weight: 600;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.04em;
white-space: nowrap;
}

.segmented-control {
display: flex;
background: var(--bg-dark);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 3px;
gap: 2px;
}

.mode-btn {
display: inline-flex;
align-items: center;
gap: 6px;
background: transparent;
border: none;
color: var(--text-muted);
padding: 7px 14px;
border-radius: 7px;
font-family: var(--font-sans);
font-size: 12.5px;
font-weight: 600;
cursor: pointer;
transition: background 0.15s var(--ease, ease), color 0.15s var(--ease, ease);
white-space: nowrap;
}

.mode-btn:hover:not(.active) {
color: var(--text-main);
background: rgba(255, 255, 255, 0.03);
}

.mode-btn.active {
background: var(--accent-teal);
color: var(--accent-teal-dark);
box-shadow: 0 2px 8px rgba(47, 217, 196, 0.25);
}

/* Main Content Area */
.app-main {
max-width: 1520px;
margin: 0 auto;
width: 100%;
padding: 28px 32px 60px;
display: flex;
flex-direction: column;
gap: 24px;
}

/* Stat Overview Bar */
.stats-overview {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
}

.stat-card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
padding: 16px 20px;
display: flex;
flex-direction: column;
gap: 4px;
box-shadow: var(--shadow-sm);
transition: var(--transition);
}

.stat-card:hover {
border-color: var(--border-strong);
transform: translateY(-1px);
}

.stat-label {
font-size: 12px;
font-weight: 600;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}

.stat-value {
font-size: 24px;
font-weight: 700;
font-family: var(--font-mono);
color: var(--text-main);
display: inline-block;
}

@keyframes stat-pulse {
0% { transform: scale(1); }
35% { transform: scale(1.18); }
100% { transform: scale(1); }
}
.stat-pulse { animation: stat-pulse 0.35s cubic-bezier(0.16, 1, 0.3, 1); }

.text-accent { color: var(--accent-teal); }
.text-warning { color: var(--status-warning); }
.text-danger { color: var(--status-danger); }

.stat-breakdown {
display: flex;
gap: 12px;
margin-top: 4px;
}

.breakdown-item {
display: inline-flex;
align-items: center;
gap: 5px;
font-size: 11px;
color: var(--text-muted);
}

.breakdown-item strong {
color: var(--text-main);
font-family: var(--font-mono);
font-weight: 600;
}

.breakdown-label { font-weight: 600; }
.text-viber { color: var(--accent-purple); }
.text-duplicate { color: var(--status-duplicate); }

/* Control & Upload Card */
.control-card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-lg);
padding: 24px;
display: flex;
flex-direction: column;
gap: 20px;
box-shadow: var(--shadow-sm);
}

.upload-dropzone {
border: 1.5px dashed var(--border-strong);
background: rgba(22, 27, 34, 0.5);
border-radius: var(--radius-md);
padding: 28px;
text-align: center;
transition: var(--transition);
position: relative;
}

.upload-dropzone:hover {
border-color: var(--accent-teal);
background: rgba(47, 217, 196, 0.02);
}

.dropzone-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
}

.dropzone-icon {
width: 48px;
height: 48px;
border-radius: 50%;
background: var(--bg-surface-elevated);
border: 1px solid var(--border-subtle);
color: var(--accent-teal);
display: flex;
align-items: center;
justify-content: center;
}

.dropzone-title {
font-size: 14px;
font-weight: 600;
color: var(--text-main);
}

.file-picker-link {
color: var(--accent-teal);
text-decoration: underline;
text-underline-offset: 3px;
cursor: pointer;
transition: var(--transition);
}

.file-picker-link:hover {
opacity: 0.85;
}

.dropzone-subtitle {
display: block;
margin-top: 4px;
font-size: 12.5px;
color: var(--text-muted);
}

.file-input-hidden {
position: absolute;
inset: 0;
opacity: 0;
cursor: pointer;
}

/* Action Bar */
.action-bar {
display: flex;
align-items: center;
gap: 16px;
padding-top: 12px;
border-top: 1px solid var(--border-subtle);
flex-wrap: wrap;
}

.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
padding: 10px 20px;
border-radius: var(--radius-md);
font-family: var(--font-sans);
font-size: 13.5px;
font-weight: 600;
border: none;
cursor: pointer;
transition: var(--transition);
white-space: nowrap;
min-width: 210px;
}

.btn-primary {
background: var(--accent-teal);
color: var(--accent-teal-dark);
box-shadow: 0 2px 10px rgba(47, 217, 196, 0.2);
}

.btn-primary:hover:not(:disabled) {
opacity: 0.9;
transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
transform: translateY(0);
}

.btn:disabled {
background: var(--bg-surface-elevated);
color: var(--text-dim);
border: 1px solid var(--border-subtle);
cursor: not-allowed;
box-shadow: none;
}

.status-indicator {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: var(--text-muted);
min-height: 20px;
}

#status { transition: opacity 0.15s ease; }

/* Table Section */
.review-container {
display: flex;
flex-direction: column;
gap: 16px;
}

.review-header {
display: flex;
flex-direction: column;
gap: 2px;
}

.review-header h2 {
font-size: 16px;
font-weight: 700;
color: var(--text-main);
}

.review-subtitle {
font-size: 13px;
color: var(--text-muted);
}

.table-card {
background: var(--bg-surface);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-lg);
overflow: hidden;
box-shadow: var(--shadow-sm);
}

.table-wrap {
overflow-x: auto;
}

table {
width: 100%;
min-width: 1200px;
border-collapse: collapse;
text-align: left;
font-size: 13px;
}

thead th {
padding: 12px 14px;
background: var(--bg-surface-elevated);
color: var(--text-muted);
font-size: 11px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.05em;
border-bottom: 1px solid var(--border-subtle);
white-space: nowrap;
}

tbody tr {
border-bottom: 1px solid var(--border-subtle);
border-left: 3px solid transparent;
transition: background 0.15s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
animation: rowFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

tbody tr:hover {
background: rgba(255, 255, 255, 0.015);
}

tbody tr.row-removing {
opacity: 0 !important;
transform: translateX(24px) !important;
transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
pointer-events: none;
}

@keyframes rowFadeIn {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}

td {
padding: 10px 14px;
vertical-align: middle;
}

.mono {
font-family: var(--font-mono);
font-size: 12.5px;
}

.file-link {
color: var(--text-main);
text-decoration: none;
border-bottom: 1px dashed var(--border-strong);
transition: var(--transition);
}
.file-link:hover {
color: var(--accent-teal);
border-bottom-color: var(--accent-teal);
}

select.medium-website { color: var(--accent-teal); font-weight: 600; }
select.medium-viber { color: var(--accent-purple); font-weight: 600; }
select.medium-needs-review { color: var(--status-warning); font-weight: 600; }

tr.bucket-website { border-left-color: var(--accent-teal); }
tr.bucket-viber { border-left-color: var(--accent-purple); }
tr.bucket-needs_review { border-left-color: var(--status-warning); }
tr.bucket-quotation { border-left-color: var(--status-danger); }
tr.bucket-duplicate { border-left-color: var(--status-duplicate); }
tr.bucket-pending { border-left-color: var(--border-strong); }

tr.bucket-quotation td.message-cell { color: var(--status-danger); font-weight: 500; }
tr.bucket-duplicate td.message-cell { color: var(--status-duplicate); }

input, select {
background: var(--bg-surface-elevated);
border: 1px solid var(--border-subtle);
color: var(--text-main);
padding: 6px 10px;
border-radius: var(--radius-sm);
font-family: inherit;
font-size: 12.5px;
width: 100%;
min-width: 0;
transition: var(--transition);
}

input:focus, select:focus {
outline: none;
border-color: var(--border-focus);
box-shadow: 0 0 0 2px var(--accent-teal-glow);
}

select {
cursor: pointer;
min-width: 128px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238e9aab' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 10px center;
padding-right: 28px;
appearance: none;
}

.f-name { min-width: 130px; }
.f-date { min-width: 92px; }
.f-amount { min-width: 78px; }
.f-order { min-width: 78px; }

.reasons {
color: var(--text-muted);
font-size: 12px;
line-height: 1.4;
}

.remove-cell {
text-align: center;
}

.remove-btn {
background: transparent;
color: var(--text-dim);
border: 1px solid transparent;
border-radius: var(--radius-sm);
width: 26px;
height: 26px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 16px;
transition: var(--transition);
margin: 0 auto;
}

.remove-btn:hover {
color: var(--status-danger);
background: var(--status-danger-glow);
border-color: rgba(248, 113, 113, 0.3);
}

.spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid var(--border-subtle);
border-top-color: var(--accent-teal);
border-radius: 50%;
animation: spin 0.7s linear infinite;
vertical-align: middle;
margin-right: 6px;
}

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

/* Blocked commit button — visually greyed like :disabled, but stays
   clickable so tapping it can open the issues popup. */
.btn.btn-blocked {
background: var(--bg-surface-elevated);
color: var(--text-dim);
border: 1px solid var(--border-subtle);
box-shadow: none;
cursor: pointer;
}
.btn.btn-blocked:hover {
border-color: var(--status-warning);
color: var(--status-warning);
opacity: 1;
transform: none;
}

/* Issues modal */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(8, 10, 13, 0.75);
backdrop-filter: blur(6px);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
padding: 20px;
}
.modal-overlay.is-active { opacity: 1; visibility: visible; pointer-events: auto; }

.modal-card {
background: var(--bg-surface-elevated);
border: 1px solid var(--border-strong);
border-radius: var(--radius-lg);
padding: 28px;
max-width: 480px;
width: 100%;
max-height: 80vh;
display: flex;
flex-direction: column;
gap: 14px;
box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
transform: scale(0.96) translateY(8px);
transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.is-active .modal-card { transform: scale(1) translateY(0); }

.modal-card h3 { font-size: 18px; font-weight: 700; color: var(--text-main); }
.modal-subtitle { font-size: 13px; color: var(--text-muted); margin-top: -8px; }

.issues-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 6px;
overflow-y: auto;
max-height: 320px;
padding-right: 4px;
margin: 0;
}

.issue-item {
display: flex;
flex-direction: column;
gap: 2px;
padding: 10px 12px;
border-radius: var(--radius-sm);
border-left: 3px solid var(--border-strong);
background: var(--bg-surface);
cursor: pointer;
transition: var(--transition);
}
.issue-item:hover { background: var(--bg-surface-hover); }
.issue-item.bucket-quotation { border-left-color: var(--status-danger); }
.issue-item.bucket-needs_review { border-left-color: var(--status-warning); }

.issue-file { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-main); }
.issue-reason { font-size: 12px; color: var(--text-muted); }

.row-highlight { animation: row-highlight-flash 1.1s ease; }
@keyframes row-highlight-flash {
0%, 100% { background: transparent; }
25% { background: rgba(47, 217, 196, 0.14); }
}


/* [hidden] must always win over the class-based display:flex rules above —
   otherwise the browser's default [hidden]{display:none} and our own
   .review-container/.empty-state-card{display:flex} tie on specificity,
   and whichever loads later wins, silently showing "hidden" elements. */
#review-section[hidden], #empty-state[hidden] { display: none !important; }

/* [hidden] must always win over the class-based display:flex/grid rules
   above — otherwise the browser's default [hidden]{display:none} and our
   own class-based display rules tie on specificity, and whichever loads
   later wins, silently showing "hidden" elements. */
#review-section[hidden], #stats-overview[hidden] { display: none !important; }

/* Hamburger — morphs into an X when open */
.hamburger-btn {
display: none;
position: relative;
width: 38px;
height: 38px;
flex-shrink: 0;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 5px;
background: var(--bg-surface-elevated);
border: 1px solid var(--border-subtle);
border-radius: 50%;
cursor: pointer;
transition: var(--transition);
z-index: 1001;
}
.hamburger-btn:hover { border-color: var(--accent-teal); }

.hamburger-btn span {
display: block;
width: 16px;
height: 1.5px;
background: var(--text-main);
border-radius: 2px;
transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.hamburger-btn.is-active span:nth-child(1) { transform: translateY(3.25px) rotate(45deg); }
.hamburger-btn.is-active span:nth-child(2) { transform: translateY(-3.25px) rotate(-45deg); }

/* Full-screen mobile category menu */
.mobile-mode-menu {
position: fixed;
inset: 0;
background: rgba(8, 10, 13, 0.96);
backdrop-filter: blur(20px);
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 40px;
z-index: 1000;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s;
}

.mobile-mode-menu.is-active {
opacity: 1;
visibility: visible;
pointer-events: auto;
}

.mobile-menu-label {
font-size: 12px;
font-weight: 600;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 24px;
}

.mobile-menu-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 8px;
}

.mobile-menu-item { overflow: hidden; }

.mobile-menu-item .mode-btn {
display: flex;
align-items: center;
gap: 16px;
width: 100%;
background: transparent;
color: var(--text-muted);
padding: 14px 4px;
border-radius: 0;
font-size: 22px;
font-weight: 500;
letter-spacing: -0.01em;
transform: translateY(110%);
transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
transition-delay: calc(0.04s * var(--i));
}

.mobile-mode-menu.is-active .mode-btn {
transform: translateY(0);
transition-delay: calc(0.1s + (0.05s * var(--i)));
}

.mobile-menu-item .mode-btn.active { color: var(--accent-teal); background: transparent; box-shadow: none; }
.mobile-menu-item .mode-btn:hover { color: var(--text-main); }

/* Responsive */
@media (max-width: 900px) {
.header-container {
flex-wrap: wrap;
}

.header-actions {
width: 100%;
display: flex;
justify-content: flex-end;
}

.hamburger-btn { display: flex; }
.mode-control-group { display: none; }
}

@media (max-width: 640px) {
.app-main, .header-container {
padding-left: 16px;
padding-right: 16px;
}

.mobile-mode-menu { padding: 0 28px; }
.mobile-menu-item .mode-btn { font-size: 19px; }
}