/* ============================================================
   IRIS FABRICS LTD - Textile Dyeing Production Tracking System
   Main Stylesheet
   ============================================================ */

/* --- CSS Variables (Theme) --- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #2563eb 100%);
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 28px;
    --wa-green: #25D366;

    /* Status Colors */
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --gray: #9ca3af;
    --gray-bg: #f3f4f6;
}

/* --- Reset & Base --- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.03) 0%, transparent 50%);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
    padding-bottom: 0;
}

/* --- Top Bar (Sticky) --- */
.top-bar {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 8px rgba(15,23,42,0.2);
    min-height: 56px;
    backdrop-filter: blur(8px);
}

/* --- Hero Section --- */
.hero-section {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 40%, #2563eb 100%);
    position: relative;
    overflow: hidden;
    padding: 40px 0 0;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -10%;
    width: 40%;
    height: 160%;
    background: radial-gradient(circle, rgba(99,102,241,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 20px 0 40px;
}

.hero-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #fff;
    backdrop-filter: blur(10px);
}

.hero-title {
    color: #fff;
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.hero-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 400;
}

/* --- Search Form --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px rgba(255,255,255,0.1);
    overflow: visible;
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.search-wrapper:focus-within {
    box-shadow: 0 8px 32px rgba(37,99,235,0.2), 0 0 0 2px rgba(37,99,235,0.3);
    transform: translateY(-1px);
}

.search-icon {
    position: absolute;
    left: 18px;
    color: var(--text-muted);
    font-size: 1.1rem;
    z-index: 5;
}

.search-input {
    border: none;
    padding: 16px 16px 16px 50px;
    font-size: 1rem;
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    background: transparent;
    height: auto;
}

.search-input:focus {
    box-shadow: none;
    background: transparent;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-btn {
    border-radius: var(--radius-xl);
    padding: 12px 24px;
    font-weight: 600;
    border: none;
    background: var(--primary);
    min-width: 100px;
    margin: 4px;
    flex-shrink: 0;
}

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

/* --- Search Results Dropdown (Instant) --- */
.search-results-dropdown {
    position: relative;
    z-index: 999;
    text-align: left;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    background: #fff;
}

.search-results-dropdown .search-result-item {
    background: #fff;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-results-dropdown .search-result-item:last-child {
    border-bottom: none;
}

.search-results-dropdown .search-result-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.search-results-dropdown .search-result-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.search-results-dropdown .search-result-item:hover {
    background: #f0f7ff;
    transform: translateX(3px);
}

.si-left {
    flex: 1;
    min-width: 0;
}

.si-batch {
    font-size: 1rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 6px;
    line-height: 1.3;
}

.si-buyer {
    font-size: 0.82rem;
    color: #334155;
    margin-bottom: 4px;
    line-height: 1.4;
}

.si-buyer i { margin-right: 2px; }

.si-ref {
    color: #94a3b8;
}

.si-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 2px;
}

.si-trims {
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.si-aplic {
    background: linear-gradient(135deg, #f97316, #eab308);
    color: #fff;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

.si-fabric {
    background: #f0fdf4;
    color: #15803d;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.si-color {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.si-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    padding-left: 8px;
}

.si-status {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.8rem;
}

.search-results-dropdown .search-result-item:last-child {
    border-bottom: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.search-results-dropdown .search-result-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.search-results-dropdown .search-result-item:hover {
    background: #f0f7ff;
}

.no-results-msg {
    background: #fff;
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Hero Wave --- */
.hero-wave {
    position: relative;
    margin-top: -2px;
    line-height: 0;
}

.hero-wave svg {
    display: block;
    width: 100%;
    height: 60px;
}

/* --- Cards --- */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-card);
}

.card:active {
    transform: scale(0.98);
}

.batch-card-sm {
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    border-color: #e2e8f0;
    border-left-color: var(--primary);
    transition: all 0.2s ease;
}

.batch-card-sm:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-left-color: var(--primary-dark);
}

.batch-card-sm .card-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Search Result Card */
.search-result-card {
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-light);
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.search-result-card:hover {
    box-shadow: var(--shadow-md);
    border-left-color: var(--primary);
}

.search-result-card .card-body {
    padding: 16px 20px;
}

@media (min-width: 768px) {
    .search-result-card .card-body {
        padding: 20px 24px;
    }
}

/* Detail Card */
.detail-card {
    border-radius: var(--radius-lg);
}

.card-body-detail {
    padding: 1rem 1rem;
}

@media (min-width: 768px) {
    .card-body-detail { padding: 2.5rem; }
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #2563eb;
    font-weight: 700;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Status Card (Shade/Quality) */
.status-card-sm {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* --- Color Swatch --- */
.color-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
    border: 1px solid var(--border-color);
}

/* --- Section Title --- */
.section-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
    letter-spacing: -0.3px;
}

/* --- Recent Section --- */
.recent-section {
    background: transparent;
}

.recent-section .section-title i {
    color: var(--primary);
}

/* --- Timeline --- */
.timeline {
    position: relative;
    padding-left: 8px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    position: relative;
}

.timeline-marker {
    width: 40px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--bg-card);
    position: relative;
    z-index: 1;
}

.timeline-content {
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}

.timeline-label {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Step Progress */
.progress-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    position: relative;
    justify-content: space-between;
}
.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 30px;
    position: relative;
}
.step-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    width: 100%;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
    border-radius: 2px;
}
.step-item.step-done:not(:last-child)::after { background: linear-gradient(90deg, #16a34a, #22c55e); }
.step-item.step-hold:not(:last-child)::after { background: linear-gradient(90deg, #dc2626, #ef4444); }
.step-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #94a3b8;
    z-index: 1;
    transition: all .3s ease;
    position: relative;
    border: 2px solid #e2e8f0;
}
.step-done .step-circle { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border-color: #16a34a; box-shadow: 0 2px 8px rgba(22,163,74,0.3); }
.step-hold .step-circle { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; border-color: #dc2626; box-shadow: 0 2px 8px rgba(220,38,38,0.3); }
.step-label {
    font-size: 0.7rem;
    margin-top: 4px;
    color: #94a3b8;
    text-align: center;
    font-weight: 500;
}
.step-done .step-label { color: #16a34a; font-weight: 600; }
.step-hold .step-label { color: #dc2626; font-weight: 600; }
.step-current .step-circle { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; border-color: #2563eb; box-shadow: 0 2px 8px rgba(37,99,235,0.3); animation: pulse 2s infinite; }
.step-current .step-label { color: #2563eb; font-weight: 600; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
    50% { box-shadow: 0 2px 16px rgba(37,99,235,0.5); }
}

.timeline-item.hold .timeline-label {
    color: var(--danger);
}

.timeline-item.pending .timeline-label {
    color: var(--text-muted);
}

/* --- Badges (Custom overrides) --- */
.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    letter-spacing: 0.2px;
}

.bg-primary { background-color: var(--primary) !important; }
.bg-primary-subtle { background-color: #dbeafe !important; }
.bg-success-subtle { background-color: var(--success-bg) !important; }
.bg-warning-subtle { background-color: var(--warning-bg) !important; }
.bg-danger-subtle { background-color: var(--danger-bg) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.bg-secondary { background-color: #94a3b8 !important; }

.badge.bg-primary,
.badge.bg-success,
.badge.bg-warning,
.badge.bg-info,
.badge.bg-secondary,
.badge.bg-danger,
.badge.bg-dark {
    color: #fff !important;
}

/* --- Status Dots (for compact timeline) --- */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-pending { background: var(--gray); }
.dot-running { background: var(--warning); }
.dot-completed { background: var(--success); }
.dot-hold { background: var(--danger); }

/* --- Floating WhatsApp Button --- */
.whatsapp-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 16px rgba(37,211,102,0.35), 0 0 0 4px rgba(37,211,102,0.1);
    z-index: 999;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
}

.whatsapp-float:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(37,211,102,0.45), 0 0 0 6px rgba(37,211,102,0.15);
    color: #fff;
}

.whatsapp-float i {
    line-height: 1;
}

/* --- Loading Spinner --- */
.loading-spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(255,255,255,0.9);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* --- Empty State --- */
.empty-state i {
    opacity: 0.5;
}

/* --- Search Hints --- */
.search-hints small {
    font-size: 0.75rem;
}

/* --- Top Search Form (search page) --- */
.top-search-form {
    flex: 1;
    max-width: 400px;
}

.top-search-input {
    border: none;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 20px 0 0 20px !important;
}

.top-search-input:focus {
    background: rgba(255,255,255,0.3);
    box-shadow: none;
    color: #fff;
}

.top-search-input::placeholder {
    color: rgba(255,255,255,0.6);
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.35s ease-out;
}

.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* --- Top Bar Back Nav --- */
.top-bar .btn-light {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
}

.top-bar .btn-light:hover {
    background: rgba(255,255,255,0.3);
}

/* --- Responsive --- */
@media (min-width: 768px) {
    .hero-title { font-size: 2.2rem; }
    .hero-subtitle { font-size: 1.1rem; }

    .search-wrapper { max-width: 600px; margin: 0 auto; }
    .whatsapp-float { width: 60px; height: 60px; font-size: 30px; }
    .detail-grid { grid-template-columns: repeat(4, 1fr); gap: 28px 32px; }
    .detail-value { font-size: 1.15rem; }
    .detail-label { font-size: 0.75rem; }
    .step-circle { width: 44px; height: 44px; font-size: 0.95rem; }
    .step-label { font-size: 0.85rem; margin-top: 6px; }
    .step-item:not(:last-child)::after { top: 22px; }
}

@media (max-width: 576px) {
    .hero-section { padding: 20px 0 0; }
    .hero-content { padding: 10px 0 30px; }
    .hero-title { font-size: 1.3rem; }
    .search-btn { min-width: 50px; }
    .search-btn span { display: none; }
    .search-input { padding: 14px 14px 14px 44px; font-size: 0.95rem; }
    .search-icon { left: 14px; font-size: 1rem; }
    .timeline { padding-left: 4px; }
    .timeline::before { left: 18px; }
    .whatsapp-float { bottom: 16px; right: 16px; width: 48px; height: 48px; font-size: 24px; }
    .batch-banner { flex-direction: column; text-align: center; gap: 8px; padding: 16px !important; }
    .batch-banner h2 { font-size: 1.4rem !important; }
    .batch-banner .text-end { text-align: center !important; }
}

/* --- Print --- */
@media print {
    .top-bar, .whatsapp-float, .search-btn { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* --- Dark Mode (prepared) --- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-card: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border-color: #334155;
    }

    body {
        background-image: 
            radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.05) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.05) 0%, transparent 50%);
    }

    .search-wrapper { background: #1e293b; border-color: #334155; }
    .search-input { color: #f1f5f9; }
    .search-input::placeholder { color: #64748b; }
    .search-results-dropdown .search-result-item { background: #1e293b; border-color: #334155; }
    .search-results-dropdown .search-result-item:hover { background: #0f172a; }
    .no-results-msg { background: #1e293b; }
    .timeline::before { background: #334155; }
    .timeline-marker { background: var(--bg-card); }
    .step-circle { background: #1e293b; color: #64748b; border-color: #334155; }
    .step-item:not(:last-child)::after { background: #334155; }
    .step-done .step-circle { background: linear-gradient(135deg, #16a34a, #22c55e); border-color: #16a34a; }
    .step-done .step-label { color: #22c55e; }
    .step-hold .step-circle { background: linear-gradient(135deg, #dc2626, #ef4444); border-color: #dc2626; }
    .step-hold .step-label { color: #ef4444; }
    .step-hold:not(:last-child)::after { background: #dc2626; }
    .step-current .step-circle { background: linear-gradient(135deg, #3b82f6, #60a5fa); color: #fff; border-color: #3b82f6; }
    .step-current .step-label { color: #60a5fa; }
    .status-card-sm { border-color: #334155; }
    .loading-spinner { background: rgba(15,23,42,0.95); }
    .hero-wave svg path { fill: var(--bg-primary); }
    .color-swatch { border-color: #475569; }
    .batch-card-sm { background: #1e293b; border-color: #334155; }
    .batch-card-sm:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
}
