/* ==========================================================================
   SORABH KITCHEN WORLD - Factory Order Follow-up CRM Styling
   Theme: Modern Industrial Dashboard (Fast, Responsive, Clean Contrast)
   ========================================================================== */

:root {
    --bg-page: #0b0f19;
    --bg-card: #131b2e;
    --bg-card-subtle: #19243c;
    --bg-surface: #1e293b;
    --bg-hover: #26354f;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    
    --primary: #f97316;
    --primary-hover: #ea580c;
    --primary-subtle: rgba(249, 115, 22, 0.15);
    
    --accent-blue: #38bdf8;
    --accent-blue-subtle: rgba(56, 189, 248, 0.15);
    
    --success: #10b981;
    --success-subtle: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --warning-subtle: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;
    --danger-subtle: rgba(239, 68, 68, 0.15);
    
    --purple: #a855f7;
    --purple-subtle: rgba(168, 85, 247, 0.15);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

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

/* ================= HEADER ================= */
.crm-header {
    background: linear-gradient(180deg, #111827 0%, rgba(17, 24, 39, 0.95) 100%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    padding: 0.85rem 1.5rem;
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #ef4444);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.4);
}

.brand-title h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-erp-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.25);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.82rem;
    transition: all 0.2s ease;
}

.btn-erp-back:hover {
    background: var(--accent-blue);
    color: #0b0f19;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
}

/* ================= MAIN CONTAINER ================= */
.main-wrapper {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ================= KPI STATS CARDS ================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-info .stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-info .stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

/* Specific Card Accents */
.stat-card.total .stat-icon { background: var(--primary-subtle); color: var(--primary); }
.stat-card.overdue .stat-icon { background: var(--danger-subtle); color: var(--danger); }
.stat-card.today .stat-icon { background: var(--warning-subtle); color: var(--warning); }
.stat-card.no-edd .stat-icon { background: var(--purple-subtle); color: var(--purple); }

/* ================= UNIT TABS BAR ================= */
.unit-tabs-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.unit-tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.unit-tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.unit-tab-btn.active {
    background: linear-gradient(135deg, var(--primary), #ea580c);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.4);
}

.unit-badge-count {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
}

.unit-tab-btn.active .unit-badge-count {
    background: rgba(0, 0, 0, 0.25);
    color: #ffffff;
}

/* ================= FILTER TOOLBAR ================= */
.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-bar-wrap {
    position: relative;
    flex: 1;
    min-width: 280px;
    max-width: 450px;
}

.search-bar-wrap i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 1.1rem;
}

.search-bar-wrap input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px 10px 42px;
    color: var(--text-main);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.quick-filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pill-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 13px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-btn:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
}

.pill-btn.active {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--primary);
}

/* ================= DATA TABLE CONTAINER ================= */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.table-responsive {
    overflow-x: auto;
    max-height: calc(100vh - 360px);
    scrollbar-width: thin;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
    white-space: nowrap;
}

.crm-table thead {
    background: var(--bg-card-subtle);
    position: sticky;
    top: 0;
    z-index: 10;
}

.crm-table th {
    padding: 12px 14px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-strong);
}

.crm-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
}

.crm-table tbody tr:hover {
    background-color: var(--bg-hover);
}

.crm-table td {
    padding: 12px 14px;
    vertical-align: middle;
}

/* Table Typography & Details */
.party-cell {
    font-weight: 700;
    color: var(--text-main);
}

.station-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.item-cell {
    font-weight: 600;
    color: #f1f5f9;
}

.sizes-badge-text {
    font-size: 0.75rem;
    color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.pending-qty-chip {
    font-weight: 800;
    color: var(--primary);
    font-size: 0.95rem;
}

.unit-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-main);
}

/* EDD Status Badges */
.edd-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 700;
}

.edd-badge.overdue {
    background: var(--danger-subtle);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
    animation: pulse-red 2s infinite;
}

.edd-badge.today {
    background: var(--warning-subtle);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.edd-badge.future {
    background: var(--success-subtle);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.edd-badge.none {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px dashed var(--border);
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Delay Reason Tag */
.delay-tag {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.delay-tag.on-track {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.2);
}

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

.btn-followup {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #ea580c);
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-followup:hover {
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    transform: translateY(-1px);
}

.btn-history {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-history:hover {
    color: var(--text-main);
    border-color: var(--border-strong);
}

/* Table Footer Summary */
.table-footer {
    padding: 12px 18px;
    background: var(--bg-card-subtle);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ================= MODALS ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-card {
    background: linear-gradient(145deg, #131c31, #1e293b);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 580px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    animation: modal-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-enter {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover { color: var(--text-main); }

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.form-group textarea {
    min-height: 90px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary:hover { color: var(--text-main); border-color: var(--border-strong); }

.btn-primary {
    padding: 8px 18px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #ea580c);
    color: #ffffff;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* ================= TIMELINE STYLING ================= */
.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    padding-left: 20px;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-strong);
}

.timeline-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.timeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.timeline-card p {
    font-size: 0.85rem;
    color: var(--text-main);
    margin-top: 4px;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
    .header-container { flex-direction: column; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
