/* Modern Premium Styling for Garment Production Stage Tracking System */
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    --warning: #f59e0b;
    --warning-light: #fffbeb;

    /* Stage Colors (Cairo Custom Palette) */
    --stage-0: #3b82f6;       /* Design (Blue) */
    --stage-0-light: #eff6ff;
    --stage-0-bg: #dbeafe;
    
    --stage-1: #db2777;       /* Sublimation (Magenta/Pink) */
    --stage-1-light: #fdf2f8;
    --stage-1-bg: #fce7f3;
    
    --stage-2: #f97316;       /* Cutting (Orange) */
    --stage-2-light: #fff7ed;
    --stage-2-bg: #ffedd5;
    
    --stage-4: #8b5cf6;       /* Sewing (Purple) */
    --stage-4-light: #f5f3ff;
    --stage-4-bg: #ede9fe;
    
    --stage-5: #d946ef;       /* Logo Printing (Pink/Violet) */
    --stage-5-light: #fdf4ff;
    --stage-5-bg: #fae8ff;
    
    --stage-6: #059669;       /* Delivery (Green) */
    --stage-6-light: #ecfdf5;
    --stage-6-bg: #d1fae5;

    /* Sidebar Theme (Premium Dark Indigo) */
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4f46e5;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(79, 70, 229, 0.05), 0 8px 10px -6px rgba(79, 70, 229, 0.05);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', 'Cairo', system-ui, -apple-system, sans-serif;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    height: 100vh;
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    background-color: var(--sidebar-bg);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px 24px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(to left, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    text-align: right;
    transition: var(--transition);
    width: 100%;
}

.nav-btn svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: var(--transition);
}

.nav-btn:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.nav-btn:hover svg {
    opacity: 1;
}

.nav-btn.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.nav-btn.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.2);
}

.user-info .name {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.user-info .role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    zoom: 0.90; /* Default scale for large desktop screens */
}

/* Responsive Auto-Zoom for Desktop Viewports to prevent squishing */
@media (min-width: 1400px) and (max-width: 1650px) {
    .main-content {
        zoom: 0.84;
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
    .main-content {
        zoom: 0.76;
    }
}

@media (min-width: 1024px) and (max-width: 1199px) {
    .main-content {
        zoom: 0.70;
    }
}

/* Header */
.main-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.9);
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    will-change: transform;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.header-title p {
    font-size: 14px;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #0f172a;
    color: white;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.btn-secondary:hover {
    background-color: #1e293b;
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 4px;
    border-radius: 50%;
}

.btn-close:hover {
    background-color: var(--border-color);
    color: var(--text-color);
}

/* Content Body */
.content-body {
    padding: 32px;
    flex-grow: 1;
}

.content-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.content-section.active {
    display: block;
}

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

/* Dashboard screen components */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-design::after { background-color: var(--stage-0); }
.card-printing::after { background-color: var(--stage-1); }
.card-sewing::after { background-color: var(--success); }
.card-delivery::after { background-color: var(--stage-4); }

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-design .card-icon { background-color: var(--stage-0-light); color: var(--stage-0); }
.card-printing .card-icon { background-color: var(--stage-1-light); color: var(--stage-1); }
.card-sewing .card-icon { background-color: var(--success-light); color: var(--success); }
.card-delivery .card-icon { background-color: var(--stage-4-light); color: var(--stage-4); }

.card-icon svg {
    width: 28px;
    height: 28px;
}

.card-data h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Dashboard Panel Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
}

.dashboard-panel {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

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

.panel-body {
    padding: 24px;
    flex-grow: 1;
}

/* SVG Chart Styles */
.chart-container {
    height: 280px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding-top: 20px;
}

.custom-bar-chart {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar-wrapper {
    width: 100%;
    max-width: 48px;
    height: 80%;
    background-color: var(--bg-color);
    border-radius: 6px;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.chart-bar {
    width: 100%;
    border-radius: 6px;
    transition: height 1s ease-out;
    cursor: pointer;
    position: relative;
    min-height: 5px;
}

.chart-bar:hover::before {
    content: attr(data-count) " طلب";
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1;
    box-shadow: var(--shadow-sm);
}

.chart-label {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Urgent Orders List */
.urgent-orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    list-style: none;
}

.urgent-order-card {
    background-color: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 4px solid var(--danger);
    transition: var(--transition);
}

.urgent-order-card:hover {
    transform: translateX(-4px);
    background-color: #f1f5f9;
}

.uo-details h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.uo-details p {
    font-size: 12px;
    color: var(--text-muted);
}

.uo-badge {
    background-color: var(--danger-light);
    color: var(--danger);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

/* Kanban Board Styling */
.kanban-board-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    padding-bottom: 12px;
    height: calc(100vh - 180px);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.kanban-board {
    display: flex;
    gap: 12px;
    height: 100%;
}

.kanban-column {
    background-color: var(--bg-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-height: 100%;
}

/* Kanban Desktop Layout: Fit all columns without scroll */
@media (min-width: 1300px) {
    .kanban-board-wrapper {
        overflow-x: hidden;
    }
    .kanban-board {
        width: 100%;
        min-width: 100%;
        gap: 8px;
    }
    .kanban-column {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* Kanban Mobile/Tablet Layout: Horizontal scrolling to prevent squishing */
@media (max-width: 1299px) {
    .kanban-board-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior-x: contain;
    }
    .kanban-board {
        width: max-content;
        min-width: 100%;
    }
    .kanban-column {
        flex: 1 0 280px;
        min-width: 280px;
        max-width: 450px;
    }
}

.kanban-column-header {
    padding: 14px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    color: white;
    font-weight: 700;
    min-height: 72px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    z-index: 2;
    position: relative;
    backdrop-filter: blur(8px);
}

/* Custom Headers per Stage */
.col-stage-0 .kanban-column-header { background: linear-gradient(135deg, #1d4ed8, #3b82f6); }
.col-stage-1 .kanban-column-header { background: linear-gradient(135deg, #be185d, #ec4899); }
.col-stage-2 .kanban-column-header { background: linear-gradient(135deg, #c2410c, #f97316); }
.col-stage-4 .kanban-column-header { background: linear-gradient(135deg, #6d28d9, #8b5cf6); }
.col-stage-5 .kanban-column-header { background: linear-gradient(135deg, #a21caf, #d946ef); }
.col-stage-6 .kanban-column-header { background: linear-gradient(135deg, #047857, #10b981); }

.column-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.column-count {
    background-color: rgba(255, 255, 255, 0.22);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
}

.kanban-cards-container {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex-grow: 1;
}


.kanban-card-divider {
    height: 1px;
    border-bottom: 3px dashed #94a3b8;
    margin: 4px 12px;
    opacity: 1;
}

/* Kanban Cards styling */
.kanban-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-right: 4px solid transparent;
    cursor: grab;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 10px;
    user-select: none;
    position: relative;
    text-align: right;
    align-items: stretch;
    min-height: 410px;
    flex-shrink: 0; /* يمنع انكماش وتداخل الكروت عند ضيق المساحة الرأسية */
}

/* توحيد ارتفاع حقل الأصناف ليكون سطرين بالضبط لمنع اختلاف الأطوال */
.kanban-card .card-title {
    margin-top: 4px !important;
    margin-bottom: 0 !important;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    height: 38px;
    min-height: 38px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

/* تنسيق موحد لاسم العميل ليبقى في سطر واحد دائماً وقصه بالنقاط الثلاث */
.card-client-badge {
    font-weight: 800;
    font-size: 15px;
    padding: 0 10px;
    height: 34px;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    direction: rtl;
    width: 100%;
    box-sizing: border-box;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
}

.card-client-badge .client-name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 24px); /* إبقاء مساحة للأيقونة */
    display: inline-block;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.col-stage-0 .kanban-card { border-right-color: var(--stage-0); }
.col-stage-1 .kanban-card { border-right-color: var(--stage-1); }
.col-stage-2 .kanban-card { border-right-color: var(--stage-2); }
.col-stage-4 .kanban-card { border-right-color: var(--stage-4); }
.col-stage-5 .kanban-card { border-right-color: var(--stage-5); }
.col-stage-6 .kanban-card { border-right-color: var(--stage-6); }

.card-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.card-id-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    background-color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-date-badge {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.card-date-badge.overdue {
    color: var(--danger);
    font-weight: 700;
}

.card-client {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-align: right;
}

.client-highlight {
    color: #0f766e; /* Premium deep teal */
    font-weight: 700;
    font-size: 13px;
    background-color: #f0fdfa; /* Light teal tint */
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    border: 1px solid #ccfbf1;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    text-align: right;
}

.card-linked-info {
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--bg-color);
    padding: 8px 10px;
    border-radius: 6px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    text-align: right;
}

.card-linked-info .info-label {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-linked-info .info-value {
    color: var(--text-color);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-card-delete {
    position: absolute;
    top: 10px;
    left: 10px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.kanban-card:hover .btn-card-delete {
    opacity: 0.6;
}

.kanban-card .btn-card-delete:hover {
    opacity: 1;
    color: var(--danger);
}

.card-quantity-badge {
    align-self: flex-start;
    background-color: #eeebff;
    color: #4f46e5;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(79, 70, 229, 0.15);
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Progress bar inside card */
.card-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.progress-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background-color: rgba(226, 232, 240, 0.5);
    border-radius: 10px;
    direction: rtl; /* يضمن بدء امتلاء الشريط من اليمين لليسار بشكل صحيح دائماً */
    border: 1px solid rgba(203, 213, 225, 0.3);
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

.col-stage-0 .progress-bar-fill {
    background: linear-gradient(90deg, #60a5fa, #2563eb);
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
}
.col-stage-1 .progress-bar-fill {
    background: linear-gradient(90deg, #f472b6, #db2777);
    box-shadow: 0 0 8px rgba(219, 39, 119, 0.6);
}
.col-stage-2 .progress-bar-fill {
    background: linear-gradient(90deg, #fb923c, #ea580c);
    box-shadow: 0 0 8px rgba(234, 88, 12, 0.6);
}
.col-stage-4 .progress-bar-fill {
    background: linear-gradient(90deg, #a78bfa, #7c3aed);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.6);
}
.col-stage-5 .progress-bar-fill {
    background: linear-gradient(90deg, #e879f9, #c026d3);
    box-shadow: 0 0 8px rgba(192, 38, 211, 0.6);
}
.col-stage-6 .progress-bar-fill {
    background: linear-gradient(90deg, #34d399, #059669);
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.6);
}

.card-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    margin-top: auto; /* Push actions to the very bottom */
    gap: 6px;
    width: 100%;
}

.card-actions > * {
    width: 100%;
}

.card-actions > div {
    display: flex;
    gap: 4px;
    width: 100%;
}

.card-actions > div > button {
    flex: 1;
}

.btn-card-action {
    background-color: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn-card-action:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.btn-card-view {
    background-color: white;
    color: #334155;
    border: 1px solid #94a3b8;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn-card-view:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    border-color: #64748b;
}

.quick-progress-buttons {
    display: flex !important;
    gap: 2px !important;
    flex-wrap: nowrap !important;
}

.btn-quick-pct {
    font-size: 9px !important;
    padding: 3px 0 !important;
    text-align: center !important;
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

/* Orders Table Styling */
.table-container-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.filter-bar {
    display: flex;
    gap: 16px;
    width: 100%;
}

.form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    background-color: var(--card-bg);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.text-input {
    flex-grow: 1;
}

.select-input {
    min-width: 200px;
}

.table-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table th, .data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f8fafc;
    font-weight: 700;
    color: var(--text-color);
    font-size: 14px;
}

.data-table td {
    font-size: 14px;
    color: #334155;
    vertical-align: middle;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge-stage-0 { background-color: var(--stage-0-light); color: var(--stage-0); }
.badge-stage-1 { background-color: var(--stage-1-light); color: var(--stage-1); }
.badge-stage-2 { background-color: var(--stage-2-light); color: var(--stage-2); }
.badge-stage-4 { background-color: var(--stage-4-light); color: var(--stage-4); }
.badge-stage-5 { background-color: var(--stage-5-light); color: var(--stage-5); }
.badge-stage-6 { background-color: var(--stage-6-light); color: var(--stage-6); }
.badge-completed { background-color: var(--success-light); color: var(--success); }

/* Workers Section Styling */
.workers-header-bar {
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-end;
}

.workers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.worker-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: var(--transition);
}

.worker-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.worker-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 16px;
}

.worker-card.idle .worker-avatar {
    background-color: var(--border-color);
    color: var(--text-muted);
}

.worker-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.worker-specialty {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.worker-status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 12px;
}

.worker-status-badge.active {
    background-color: var(--success-light);
    color: var(--success);
}

.worker-status-badge.idle {
    background-color: #f1f5f9;
    color: #475569;
}

.worker-assignment {
    width: 100%;
    text-align: center;
    padding: 10px;
    background-color: var(--bg-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-color);
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.worker-action-delete {
    position: absolute;
    top: 12px;
    left: 12px;
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition);
}

.worker-action-delete:hover {
    color: var(--danger);
}

.worker-action-edit {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition);
}

.worker-action-edit:hover {
    color: var(--primary);
}

/* Timeline/Log Screen Styling */
.logs-timeline {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.logs-timeline::before {
    content: '';
    position: absolute;
    top: 24px;
    bottom: 24px;
    right: 48px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    position: relative;
}

.timeline-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    z-index: 2;
    transition: var(--transition);
}

.timeline-item:hover .timeline-icon {
    border-color: var(--primary);
    color: var(--primary);
    background-color: var(--primary-light);
}

.timeline-icon svg {
    width: 20px;
    height: 20px;
}

.timeline-content {
    background-color: var(--bg-color);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    flex-grow: 1;
    border: 1px solid var(--border-color);
}

.timeline-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 6px;
}

.timeline-desc {
    font-size: 13px;
    color: #475569;
}

.timeline-note {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: var(--card-bg);
    border-right: 3px solid var(--primary);
    font-style: italic;
    font-size: 12px;
    border-radius: 4px;
}

/* Modals styling */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-backdrop.open .modal-card {
    transform: translateY(0);
}

.modal-card.modal-sm {
    max-width: 500px;
}

.modal-card.modal-lg {
    max-width: 1200px;
}

@media (min-width: 1024px) {
    .modal-card.modal-lg .modal-body {
        overflow-x: hidden;
    }
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
}

.modal-form {
    padding: 24px;
}

.modal-body {
    padding: 16px 20px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label,
#change-password-modal label,
#reassign-worker-modal label,
#start-work-modal label {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
}

.form-group label .required {
    color: var(--danger);
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.order-info-badge {
    background-color: var(--primary-light);
    border: 1px solid rgba(79, 70, 229, 0.1);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.order-info-badge strong {
    color: var(--primary);
}

/* Details view timeline */
.details-timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.details-timeline-item {
    display: flex;
    gap: 12px;
    position: relative;
    padding-bottom: 4px;
}

.details-timeline-item:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 24px;
    right: 12px;
    bottom: -10px;
    width: 2px;
    background-color: var(--border-color);
}

.details-timeline-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: var(--border-color);
    border: 2px solid white;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.details-timeline-dot.active {
    background-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.details-timeline-dot.completed {
    background-color: var(--success);
}

.details-timeline-content {
    background-color: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    flex-grow: 1;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-timeline-text h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-color);
}

.details-timeline-text p {
    font-size: 12px;
    color: var(--text-muted);
}

.details-timeline-date {
    font-size: 11px;
    color: var(--text-muted);
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    padding: 24px;
}

.details-summary {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.details-summary-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 5px;
    font-size: 13px;
}

.details-summary-row span:first-child {
    color: var(--text-muted);
    font-weight: 500;
}

.details-summary-row span:last-child {
    color: var(--text-color);
    font-weight: 700;
}

.details-notes-box {
    margin-top: 14px;
    background-color: #fffbeb;
    border-right: 4px solid var(--warning);
    padding: 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #78350f;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive styles */
@media (max-width: 768px) {
    html, body {
        height: 100%;
        overflow: hidden;
        position: relative;
        overscroll-behavior: none;
    }

    .app-container {
        grid-template-columns: 1fr;
        height: 100%;
        height: 100dvh;
    }
    
    .main-content {
        height: 100%;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .main-header {
        position: relative !important;
        top: auto !important;
        backdrop-filter: none !important;
        background-color: var(--card-bg) !important;
        transform: none !important;
        will-change: auto !important;
    }

    .sidebar {
        display: flex;
        position: fixed;
        right: -280px;
        top: 0;
        height: 100%;
        height: 100dvh;
        width: 280px;
        transition: right 0.3s ease;
        z-index: 1000;
        box-shadow: -4px 0 24px rgba(0,0,0,0.5);
    }
    
    .sidebar.open {
        right: 0;
    }
    
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.open {
        display: block !important;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .kanban-card {
        touch-action: auto;
    }
}

/* Login Screen Styling */
.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgb(15, 23, 42) 0%, rgb(30, 41, 59) 90.1%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    padding: 40px 32px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    animation: loginFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    max-height: 60px;
    width: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    margin-bottom: 16px;
    background-color: transparent;
}

.login-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 6px;
}

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
}

.login-error {
    background-color: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-top: 15px;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--sidebar-text);
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    margin-right: auto;
}

.btn-logout:hover {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Image Upload Frames */
.image-upload-frame {
    transition: all 0.2s ease-in-out;
}

.image-upload-frame:hover {
    border-color: var(--primary) !important;
    background-color: #f8fafc !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.btn-remove-image {
    transition: all 0.2s ease-in-out;
    display: flex;
}

.btn-remove-image:hover {
    transform: scale(1.1);
    background-color: var(--danger) !important;
}



:root {
    --stage-3: #06b6d4;       /* Heat Press (Cyan) */
    --stage-3-light: #cffafe;
    --stage-3-bg: #ecfeff;
}
.col-stage-3 .kanban-column-header { background: linear-gradient(135deg, #0e7490, #06b6d4); }
.col-stage-3 .kanban-card { border-right-color: var(--stage-3); }
.col-stage-3 .progress-bar-fill {
    background: linear-gradient(90deg, #22d3ee, #0891b2);
    box-shadow: 0 0 8px rgba(8, 145, 178, 0.6);
}
.badge-stage-3 { background-color: var(--stage-3-light); color: var(--stage-3); }
#reports-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px !important;
}

#reports-data-table th {
    background-color: #0f172a !important; /* لون ترويسة أغمق وأفخم */
    color: #ffffff !important;
    font-weight: 800 !important;
    padding: 12px 10px !important;
    font-size: 14px !important;
    border: 1px solid #1e293b !important;
    white-space: nowrap !important; /* Keep header text horizontal and prevent clipping */
    vertical-align: middle !important;
    line-height: 1.3;
}

#reports-data-table td {
    padding: 10px 8px !important;
    font-size: 13.5px !important; /* تكبير حجم الخط */
    border: 1px solid #cbd5e1 !important; /* حدود داكنة وأوضح لتحديد الخلايا */
    color: #0f172a !important; /* لون نص شديد التباين والوضوح */
    font-weight: 700 !important; /* خط سميك وواضح للأرقام والنصوص العربية */
    vertical-align: middle !important;
    white-space: nowrap !important;
    line-height: 1.3;
}

/* Responsive Table Adjustments */
@media (max-width: 768px) {
    #reports-data-table {
        min-width: 1600px !important; /* Force horizontal scroll on mobile for 21 columns to prevent squishing */
    }
    .data-table {
        min-width: 900px !important; /* Prevent main orders table from squishing on mobile */
    }
}

@media (min-width: 769px) {
    #reports-data-table {
        min-width: unset !important; /* Fit screen on desktop */
    }
}

#reports-data-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

#reports-data-table tbody tr:hover {
    background-color: #f1f5f9 !important;
}

/* Custom Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.custom-toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-right: 5px solid #cbd5e1;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #1e293b;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    font-weight: 600;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s, margin 0.3s;
    opacity: 0;
    direction: rtl;
}
.custom-toast.show {
    transform: translateX(0);
    opacity: 1;
}
.custom-toast.success {
    border-right-color: #10b981;
}
.custom-toast.error {
    border-right-color: #ef4444;
}
.custom-toast.warning {
    border-right-color: #f59e0b;
}
.custom-toast.info {
    border-right-color: #3b82f6;
}
.custom-toast-icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.custom-toast.success .custom-toast-icon { color: #10b981; }
.custom-toast.error .custom-toast-icon { color: #ef4444; }
.custom-toast.warning .custom-toast-icon { color: #f59e0b; }
.custom-toast.info .custom-toast-icon { color: #3b82f6; }

/* Custom Confirm Modal */
.custom-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    direction: rtl;
}
.custom-confirm-overlay.show {
    opacity: 1;
}
.custom-confirm-modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 24px;
    transform: scale(0.9);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'Cairo', sans-serif;
}
.custom-confirm-overlay.show .custom-confirm-modal {
    transform: scale(1);
}
.custom-confirm-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.custom-confirm-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fef3c7;
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.custom-confirm-icon.danger {
    background: #fee2e2;
    color: #dc2626;
}
.custom-confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}
.custom-confirm-body {
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 24px;
}
.custom-confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.custom-confirm-btn {
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.custom-confirm-btn-cancel {
    background: #f1f5f9;
    color: #475569;
}
.custom-confirm-btn-cancel:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.custom-confirm-btn-confirm {
    background: var(--primary);
    color: white;
}
.custom-confirm-btn-confirm:hover {
    opacity: 0.9;
}
.custom-confirm-btn-confirm.danger {
    background: #dc2626;
}
.custom-confirm-btn-confirm.danger:hover {
    background: #b91c1c;
}

/* Responsive layout for the order details modal */
.order-view-flex-container {
    display: flex;
    flex-direction: row-reverse;
    gap: 30px;
    text-align: right;
    direction: rtl;
    padding: 10px;
}

.order-table-scroll-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 30px;
    border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
    .order-view-flex-container {
        flex-direction: column-reverse;
        gap: 20px;
    }
}

/* Reassign worker trigger interactive link styling */
.reassign-worker-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    margin-right: 6px;
    border-radius: 50%;
    background-color: transparent;
    transition: background-color 0.2s, transform 0.2s;
    cursor: pointer !important;
}
.reassign-worker-trigger:hover {
    background-color: rgba(37, 99, 235, 0.12);
}
.reassign-worker-trigger:hover .reassign-svg {
    transform: rotate(180deg);
    color: #1d4ed8 !important;
}

/* Hide HTML5 Up/Down Spinners Globally for Cleaner and Wider inputs */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

/* --- Group Chat Drawer Styles --- */
.chat-drawer {
    position: fixed;
    top: 0;
    left: -420px; /* Hidden initially (slides from left) */
    width: 400px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
}

.chat-drawer.open {
    left: 0;
}

.chat-drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--panel-header-bg, #f8fafc);
}

.chat-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
}

.chat-header-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.chat-drawer-close:hover {
    background-color: var(--border-color);
}

.chat-drawer-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Scrollbar styling for messages */
.chat-drawer-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-drawer-messages::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 6px 10px;
    border-radius: 10px;
    position: relative;
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
}

.chat-message-bubble.incoming {
    align-self: flex-start;
    background-color: #f1f5f9;
    color: #0f172a;
    border-top-left-radius: 2px;
    border: 1px solid #e2e8f0;
}

.chat-message-bubble.outgoing {
    align-self: flex-end;
    background-color: #4f46e5;
    color: #ffffff;
    border-top-right-radius: 2px;
}

.chat-msg-sender {
    font-weight: 700;
    font-size: 10.5px;
    margin-bottom: 2px;
    display: block;
    color: inherit;
}

.chat-message-bubble.outgoing .chat-msg-sender {
    color: rgba(255, 255, 255, 0.95);
}

.chat-message-bubble.incoming .chat-msg-sender {
    color: #4f46e5;
}

.chat-msg-text {
    display: block;
    color: inherit;
}

.chat-msg-image {
    max-width: 220px;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    margin-top: 4px;
    cursor: pointer;
    display: block;
}

.chat-message-bubble.image-only {
    padding: 5px;
    border-radius: 8px;
}

.chat-msg-time {
    font-size: 8.5px;
    margin-top: 2px;
    display: block;
    text-align: left;
    opacity: 0.7;
    color: inherit;
}

.chat-drawer-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.chat-preview-container {
    position: relative;
    margin-bottom: 12px;
    display: inline-block;
}

#chat-image-preview {
    max-width: 100px;
    max-height: 100px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: block;
}

.chat-preview-remove {
    position: absolute;
    top: -6px;
    left: -6px;
    background-color: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

#chat-message-input {
    flex: 1;
    height: 38px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 19px;
    font-size: 13px;
    background-color: var(--input-bg, #ffffff);
    color: var(--text-color);
}

.chat-attach-btn, .chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-attach-btn {
    background-color: var(--border-color);
    color: var(--text-color);
}

.chat-attach-btn:hover {
    background-color: var(--text-muted);
    color: white;
}

.chat-send-btn {
    background-color: var(--primary);
    color: white;
}

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

/* Chat Unread Badge styling */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--card-bg);
}

.chat-btn-container {
    position: relative;
    display: inline-block;
}

/* Make sure mobile views are friendly */
@media (max-width: 480px) {
    .chat-drawer {
        width: 100%;
        left: -100%;
        height: 100vh;
        height: 100dvh;
    }
}

/* Camera Modal Styles */
.camera-modal-card {
    max-width: 500px;
    padding: 16px;
    position: relative;
    text-align: center;
    direction: rtl;
    width: 90%;
    border-radius: var(--radius-md);
    background-color: var(--card-bg);
}

.camera-video-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    margin: 0 auto 16px auto;
    aspect-ratio: 4/3;
    background-color: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.camera-video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 768px) {
    #chat-camera-modal .modal-card {
        max-width: 100% !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex;
        flex-direction: column;
        background-color: #000 !important;
        justify-content: space-between;
    }
    
    #chat-camera-modal .modal-card h3 {
        color: white !important;
        position: absolute;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 10;
        margin: 0 !important;
        text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    }
    
    #chat-camera-modal .btn-close {
        top: 16px !important;
        right: 16px !important;
        background: rgba(255,255,255,0.2) !important;
        border: none !important;
        color: white !important;
        z-index: 12 !important;
    }
    
    #chat-camera-modal .camera-video-container {
        max-width: 100% !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        aspect-ratio: unset !important;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
    }
    
    #chat-camera-modal .camera-video-container video {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    #chat-camera-modal .camera-controls {
        position: absolute;
        bottom: 40px;
        left: 0;
        width: 100%;
        display: flex;
        gap: 20px;
        justify-content: center;
        z-index: 10;
        padding: 0 16px;
    }
}
