/* Kitchen Display System (KDS) Styles */

/* Vertical Layout for Orders Container */
.orders-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    max-width: 100%;
    margin: 0 auto;
}

/* Order Card Vertical Layout */
.order-card {
    width: 100%;
    max-width: 800px;
    margin: 0 auto 15px 0;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 15px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    cursor: default;
}

.order-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    border-color: #007bff;
}

/* Cancelled Order Styling */
.order-card.cancelled {
    background: rgba(220, 53, 69, 0.1);
    border: 2px solid #dc3545;
    position: relative;
}

.order-card.cancelled::before {
    content: "CANCELLED";
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.order-card.cancelled .order-header {
    background: #dc3545 !important;
    color: white !important;
}

.order-card.cancelled .items-list {
    opacity: 0.7;
}

.order-card.cancelled .item-name {
    text-decoration: line-through;
    color: #dc3545;
}

/* Additional KDS-specific styles */
.kds-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

/* Item modifiers styling */
.item-modifiers {
    font-size: 11px !important;
    color: #ffc107 !important; /* Golden/yellow color for high visibility */
    font-weight: 500;
    line-height: 1.2;
    margin-top: 2px !important;
    padding-left: 2px;
    font-style: italic;
}

/* Ensure item-row has proper spacing for modifiers */
.item-row {
    padding: 8px 12px;
    margin-bottom: 6px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    transition: all 0.2s ease;
}

.item-row:hover {
    background: rgba(255,255,255,0.1);
}

/* Adjust item name and quantity spacing */
.item-quantity {
    font-weight: bold;
    color: #ffffff;
    min-width: 30px;
}

.item-name {
    font-weight: 600;
    color: #ffffff;
}

/* Station management styles */
.station-management {
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    backdrop-filter: blur(10px);
}

.station-item {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.station-item:hover {
    background: rgba(255,255,255,0.15);
    transform: translateX(5px);
}

.station-item.active {
    background: rgba(255,255,255,0.2);
    border-left: 4px solid #28a745;
}

/* Order priority indicators */
.priority-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.priority-indicator.normal { background: #28a745; }
.priority-indicator.urgent { background: #ffc107; }
.priority-indicator.rush { 
    background: #dc3545; 
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Timer styles */
.order-timer {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.timer-normal {
    background: rgba(40, 167, 69, 0.8);
    color: #ffffff;
    font-weight: bold;
}

.timer-warning {
    background: rgba(255, 193, 7, 0.8);
    color: #000000;
}

.timer-danger {
    background: rgba(220, 53, 69, 0.8);
    color: #ffffff;
}

/* Timer-based header colors for KDS - Professional three-color system */
.order-header.timer-normal {
    background: #28a745 !important; /* Professional green for new orders */
    color: #ffffff !important; /* White text for prominence */
    border-bottom-color: #1e7e34 !important;
}

.order-header.timer-warning {
    background: #ffc107 !important; /* Professional yellow for last minutes */
    color: #212529 !important; /* Dark text for prominence */
    border-bottom-color: #e0a800 !important;
}

.order-header.timer-danger {
    background: #dc3545 !important; /* Professional red for time over */
    color: #ffffff !important; /* White text for prominence */
    border-bottom-color: #c82333 !important;
}

.order-header.timer-critical {
    background: #dc3545 !important; /* Professional red for time over */
    color: #ffffff !important; /* White text for prominence */
    border-bottom-color: #c82333 !important;
}

/* Table and floor info styling */
.table-floor-info {
    font-size: 22px;
    font-weight: bold;
    color: inherit;
    margin-bottom: 5px;
}

.table-floor-info .table-name {
    color: inherit; /* Inherits from parent timer color for prominence */
    font-weight: 800;
}

.table-floor-info .floor-name {
    color: inherit; /* Inherits from parent timer color for prominence */
    font-weight: 600;
}

/* Order number styling for dine-in orders */
.order-number {
    font-size: 16px;
    font-weight: 600;
    color: #666;
    margin-top: 5px;
}

/* Special instructions styling */
.special-instructions {
    position: relative;
    padding-left: 30px;
}

.special-instructions::before {
    content: "⚠";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: #ffc107;
}

/* Order type badges */
.order-type-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

/* Running order badge - prominent styling */
.running-order-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #dc3545, #ff6b6b);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

/* Cancelled order badge - similar to running order but with different colors */
.cancelled-order-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #dc3545, #dc3545);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

/* Running order card styling */
.order-card.running-order {
    border: 2px solid #ffc107;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.3);
    position: relative;
}

/* Running order item label */
.running-order-item-label {
    background: linear-gradient(135deg, #ffc107 0%, #ff8c00 100%);
    color: #000;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
    animation: pulse-running 2s infinite;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Item row styling */
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.item-row:last-child {
    border-bottom: none;
}

.item-row .d-flex {
    flex: 1;
    min-width: 0; /* Allow flex items to shrink */
}

.item-name {
    flex: 1;
    min-width: 0; /* Allow text to wrap */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.order-type-badge.dine-in {
    background: #28a745;
    color: #ffffff;
}

.order-type-badge.takeaway,
.order-type-badge.take_away {
    background: #17a2b8;
    color: #ffffff;
}

.order-type-badge.delivery {
    background: #6f42c1;
    color: #ffffff;
}

/* Table info styling */
.table-info {
    display: inline-block;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 500;
    color: #ffffff;
    margin-left: 8px;
}

/* Order served animation */
.order-served {
    background: rgba(40, 167, 69, 0.3) !important;
    border-color: #28a745 !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

/* Item status styling */
.item-status.served {
    background: #28a745;
    color: white;
    font-weight: bold;
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Preparation notes */
.preparation-notes {
    background: rgba(23, 162, 184, 0.2);
    border: 1px solid rgba(23, 162, 184, 0.5);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    color: #17a2b8;
    font-style: italic;
}

/* Item customization */
.item-customization {
    background: rgba(108, 117, 125, 0.2);
    border: 1px solid rgba(108, 117, 125, 0.5);
    border-radius: 6px;
    padding: 8px;
    margin: 5px 0;
    font-size: 12px;
    color: #6c757d;
}

/* Kitchen staff info */
.staff-info {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: #cccccc;
    margin-top: 10px;
}

/* Order completion progress */
.order-progress {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
}

.progress-bar {
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 0.3s ease;
}

/* Responsive design for different screen sizes */
@media (max-width: 1200px) {
    .orders-grid {
        max-width: 90%;
    }
    
    .order-card {
        max-width: 700px;
        margin-bottom: 15px;
    }
    
    .order-number {
        font-size: 20px;
    }
    
    .item-name {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .orders-grid {
        max-width: 95%;
        padding: 15px;
        gap: 12px;
    }
    
    .kds-header h1 {
        font-size: 24px;
    }
    
    .station-tab {
        padding: 10px 15px;
        font-size: 14px;
        margin: 0 2px;
    }
    
    .order-card {
        max-width: 100%;
        margin-bottom: 10px;
    }
    
    .order-header {
        padding: 10px;
    }
    
    .order-number {
        font-size: 18px;
    }
    
    .order-body {
        padding: 15px;
    }
    
    .item-name {
        font-size: 20px;
    }
    
    .btn-kds {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .order-actions {
        padding: 10px;
        flex-wrap: wrap;
        gap: 5px;
    }
}

@media (max-width: 576px) {
    .orders-grid {
        max-width: 100%;
        padding: 10px;
        gap: 10px;
    }
    
    .kds-header {
        padding: 10px 0;
    }
    
    .kds-header h1 {
        font-size: 20px;
    }
    
    .station-tab {
        padding: 8px 12px;
        font-size: 12px;
        margin: 0 1px;
    }
    
    .order-card {
        max-width: 100%;
        margin-bottom: 8px;
    }
    
    .order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .order-number {
        font-size: 16px;
    }
    
    .order-body {
        padding: 10px;
    }
    
    .item-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .btn-kds {
        padding: 6px 12px;
        font-size: 11px;
        flex: 1;
        min-width: 80px;
    }
}

/* Print styles for KDS */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .kds-header,
    .station-tab,
    .status-indicator,
    .refresh-indicator,
    .order-actions {
        display: none;
    }
    
    .order-card {
        background: white;
        border: 1px solid #ccc;
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
    
    .order-header {
        background: #f8f9fa;
        color: black;
    }
    
    .order-body {
        color: black;
    }
    
    .item-row {
        border-bottom: 1px solid #eee;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .order-card,
    .station-tab,
    .btn-kds,
    .priority-indicator.rush {
        animation: none;
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .order-card {
        border: 2px solid #ffffff;
    }
    
    .order-header {
        background: #ffffff;
        color: #000000;
    }
    
    .btn-kds {
        border: 2px solid #ffffff;
    }
}

/* Dark mode variations */
[data-theme="dark"] .order-card {
    background: rgba(0,0,0,0.8);
    border-color: rgba(255,255,255,0.3);
}

[data-theme="dark"] .order-header {
    background: rgba(0,0,0,0.9);
}

/* Loading states */
.kds-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #cccccc;
}

.kds-loading::after {
    content: "";
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error states */
.kds-error {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid rgba(220, 53, 69, 0.5);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    color: #dc3545;
    text-align: center;
}

.kds-error i {
    font-size: 24px;
    margin-bottom: 10px;
}

/* Success states */
.kds-success {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid rgba(40, 167, 69, 0.5);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    color: #28a745;
    text-align: center;
}

.kds-success i {
    font-size: 24px;
    margin-bottom: 10px;
}

/* KDS Management Page Styles */

/* Color preview for station management */
.color-preview {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
    border: 2px solid #ddd;
    flex-shrink: 0;
}

/* Setting items styling */
.setting-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #28a745;
    transition: all 0.3s ease;
}

.setting-item:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.setting-item label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

.setting-item small {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Form control styling for settings */
.setting-item .form-control {
    border-radius: 6px;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.setting-item .form-control:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Button styling for settings */
.setting-item .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.setting-item .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Table styling for assignments */
.assignments-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.assignments-table thead th {
    background: #343a40;
    color: white;
    border: none;
    padding: 12px 15px;
    font-weight: 600;
}

.assignments-table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
}

.assignments-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Form control styling for assignments */
.assignments-table .form-control-sm {
    border-radius: 4px;
    border: 1px solid #ced4da;
    padding: 6px 10px;
    font-size: 0.875rem;
}

.assignments-table .form-control-sm:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Filter section styling */
.filter-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.filter-section .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
}

/* Responsive adjustments for management page */
@media (max-width: 768px) {
    .setting-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .setting-item .d-flex {
        flex-direction: column;
        gap: 10px;
    }
    
    .setting-item .btn-primary {
        width: 100%;
    }
    
    .color-preview {
        width: 25px;
        height: 25px;
        margin-right: 8px;
    }
    
    .assignments-table {
        font-size: 0.875rem;
    }
    
    .assignments-table thead th,
    .assignments-table tbody td {
        padding: 8px 10px;
    }
}

/* Dark mode support for management page */
[data-layout-mode=dark_mode] .setting-item {
    background: #3a3f4b;
    border-left-color: #28a745;
    color: #ffffff;
}

[data-layout-mode=dark_mode] .setting-item:hover {
    background: #4a4f5b;
}

[data-layout-mode=dark_mode] .setting-item label {
    color: #ffffff;
}

[data-layout-mode=dark_mode] .setting-item small {
    color: #b8bcc9;
}

[data-layout-mode=dark_mode] .assignments-table {
    background: #3a3f4b;
    color: #ffffff;
}

[data-layout-mode=dark_mode] .assignments-table tbody tr:hover {
    background-color: #4a4f5b;
}

[data-layout-mode=dark_mode] .filter-section {
    background: #3a3f4b;
    border-color: #4a4f5b;
    color: #ffffff;
}

[data-layout-mode=dark_mode] .filter-section .form-label {
    color: #ffffff;
}

/* Responsive item row */
@media (max-width: 768px) {
    .item-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .item-row .d-flex {
        width: 100%;
        justify-content: flex-start;
    }
    
    .item-name {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .running-order-item-label {
        font-size: 9px;
        padding: 1px 6px;
        margin-left: 4px;
    }
    
    /* Responsive table/floor info */
    .table-floor-info {
        font-size: 18px;
    }
    
    .order-number {
        font-size: 14px;
    }
}

@media (max-width: 576px) {
    .table-floor-info {
        font-size: 16px;
    }
    
    .order-number {
        font-size: 12px;
    }
}

@media (max-width: 576px) {
    .item-name {
        max-width: 150px;
    }
    
    .running-order-item-label {
        font-size: 8px;
        padding: 1px 4px;
        margin-left: 2px;
    }
}

/* Station selector styling */
.station-selector {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
}

.station-dropdown {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #333;
    font-weight: 600;
    padding: 10px 15px;
    transition: all 0.3s ease;
}

.station-dropdown:focus {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    outline: none;
}

.station-dropdown option {
    background: white;
    color: #333;
    padding: 10px;
}

#refresh-orders {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: white;
    padding: 10px 15px;
    transition: all 0.3s ease;
}

#refresh-orders:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

#refresh-orders:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Responsive station selector */
@media (max-width: 768px) {
    .station-selector {
        padding: 10px;
    }
    
    .station-selector .d-flex {
        flex-direction: column;
        gap: 10px;
    }
    
    .station-dropdown {
        max-width: 100% !important;
        font-size: 14px;
    }
    
    #refresh-orders {
        align-self: center;
    }
}

@media (max-width: 576px) {
    .station-selector {
        padding: 8px;
    }
    
    .station-dropdown {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .station-selector label {
        font-size: 14px;
    }
}
