/* ═══════════════════════════════════════════════════════════════
   نظام الكاشير - ملك الطابون
   Cashier System Styles
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   المتغيرات الأساسية - CSS Variables
   ═══════════════════════════════════════════════════════════════ */
:root {
    --primary: #FF5722;
    --dark: #1a1a1a;
    --light: #f4f4f4;
    --white: #fff;
    --gray: #666;
    --border: #ddd;
    --accent: #FF5722;
}

/* ═══════════════════════════════════════════════════════════════
   Reset وأنماط عامة - Reset & General Styles
   ═══════════════════════════════════════════════════════════════ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--light);
    height: 100vh;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   أنماط تسجيل الدخول - Login Styles
   ═══════════════════════════════════════════════════════════════ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--dark) 100%);
}

.login-container {
    background: var(--white);
    padding: 32px;
    border-radius: 20px;
    width: 92%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
    animation: loginSlideIn 0.4s ease-out;
}

@keyframes loginSlideIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h1 {
    color: var(--primary);
    margin-bottom: 4px;
    font-size: 1.75rem;
    font-weight: 700;
}

.login-header p {
    color: var(--gray);
    margin-bottom: 0;
    font-size: 0.95rem;
}

.logo-icon {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 10px;
}

.login-header .logo-icon i {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.cashier-subtitle {
    color: var(--accent);
    font-size: 0.95rem;
    margin-top: 5px;
    font-weight: 500;
}

/* ─── Employee Grid Section ─── */
.login-employees-section {
    margin-bottom: 16px;
}

.login-employees-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f4f4f4;
}

.login-employees-label span {
    font-weight: 700;
    font-size: 1rem;
    color: #333;
}

.btn-refresh-employees {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-refresh-employees:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.login-employees-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px;
}

.login-employees-grid::-webkit-scrollbar {
    width: 4px;
}

.login-employees-grid::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 9999px;
}

.login-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px;
    color: #999;
    font-size: 0.9rem;
}

.login-loading i {
    font-size: 2rem;
}

/* ─── Employee Card ─── */
.login-employee-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px 12px;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    min-height: 100px;
    justify-content: center;
}

.login-employee-card:hover {
    border-color: var(--primary);
    background: #fff5f2;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.login-employee-card:active {
    transform: scale(0.96);
}

.emp-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.emp-card-avatar.role-admin {
    background: linear-gradient(135deg, #FF5722, #e64a19);
}

.emp-card-avatar.role-manager {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.emp-card-avatar.role-cashier {
    background: linear-gradient(135deg, #10b981, #059669);
}

.emp-card-avatar.role-viewer {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.emp-card-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #333;
    line-height: 1.3;
    word-break: break-word;
}

.emp-card-role {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    color: white;
}

.emp-card-role.role-admin {
    background: var(--primary);
}

.emp-card-role.role-manager {
    background: #3b82f6;
}

.emp-card-role.role-cashier {
    background: #10b981;
}

.emp-card-role.role-viewer {
    background: #8b5cf6;
}

.emp-lock-icon {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 0.65rem;
    color: #999;
    opacity: 0.6;
}

/* ─── PIN Input Section ─── */
.login-pin-section {
    animation: pinSlideIn 0.3s ease-out;
}

@keyframes pinSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-selected-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: linear-gradient(135deg, #fff5f2 0%, #ffe8e0 100%);
    border: 1px solid var(--primary);
    border-radius: 12px;
    margin-bottom: 16px;
}

.login-selected-info i.fa-user-check {
    color: var(--primary);
    font-size: 1.2rem;
}

.login-selected-info span {
    flex: 1;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--dark);
}

.btn-change-employee {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-change-employee:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-field {
    position: relative;
    display: flex;
    align-items: center;
    background-color: var(--light);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.15s ease;
}

.login-field:focus-within {
    border-color: var(--primary);
}

.login-field i {
    color: #999;
    font-size: 1.1rem;
    margin-left: 8px;
}

.login-field input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: #333;
    letter-spacing: 4px;
    text-align: center;
    font-family: 'Tajawal', sans-serif;
    outline: none;
}

.login-field input::placeholder {
    color: #999;
    letter-spacing: 0;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background-color: rgba(220, 53, 69, 0.1);
    border: 1px solid #dc3545;
    border-radius: 12px;
    color: #dc3545;
    font-size: 0.9rem;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 4px;
}

.btn-login:hover:not(:disabled) {
    background-color: #e64a19;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.btn-login:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #999;
    font-size: 0.85rem;
}

/* ─── Login Mobile ─── */
@media (max-width: 480px) {
    .login-employees-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .login-container {
        padding: 20px;
    }
}

.hidden {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════
   أنماط الكاشير الرئيسية - Main Cashier Styles
   ═══════════════════════════════════════════════════════════════ */
.cashier-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--light);
}

.cashier-header {
    background: var(--dark);
    color: var(--white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.cashier-header .logo {
    font-size: 1.3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cashier-header .logo i {
    color: var(--accent);
    font-size: 1.5rem;
}

.cashier-header .user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cashier-header .user-info span {
    font-size: 0.95rem;
    font-weight: 500;
}

.cashier-header .user-info button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cashier-header .user-info button:hover {
    background: rgba(255,255,255,0.2);
}

.cashier-main {
    flex: 1;
    padding: 15px 20px;
    overflow-y: auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.page-title {
    font-size: 1.2rem;
    color: var(--dark);
}

/* ═══════════════════════════════════════════════════════════════
   أنماط الطلبات - Orders Styles
   ═══════════════════════════════════════════════════════════════ */

/* Orders Header */
.refresh-countdown {
    position: fixed;
    left: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 30, 46, 0.85);
    backdrop-filter: blur(8px);
    color: #94a3b8;
    font-size: 12px;
    font-family: 'Tajawal', monospace;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    z-index: 999;
    direction: ltr;
    user-select: none;
    transition: opacity 0.3s;
}
.refresh-countdown i {
    font-size: 10px;
    opacity: 0.6;
}
.refresh-countdown:hover {
    opacity: 0.5;
}

.orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.orders-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Filter Buttons */
.order-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Sound Toggle */
.sound-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #22c55e;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.sound-toggle-btn:hover {
    transform: scale(1.1);
}

.sound-toggle-btn.muted {
    background: #ef4444;
}

/* Orders Stats */
.orders-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.order-stat {
    background: var(--white);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-right: 3px solid var(--gray);
    transition: all 0.2s ease;
}

.order-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.order-stat.new {
    border-color: #3b82f6;
}

.order-stat.preparing {
    border-color: #f97316;
}

.order-stat.ready {
    border-color: #22c55e;
}

.order-stat.revenue {
    border-color: #d4a853;
}

.stat-label {
    display: block;
    font-size: 0.78rem;
    color: var(--gray);
    margin-bottom: 3px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--dark);
}

/* Stat Highlight Animation */
@keyframes statPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.order-stat.highlight {
    animation: statPulse 0.5s ease;
}

/* Orders Grid */
.orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    align-items: stretch;
}

/* ═══════════════════════════════════════════════════════════════
   بطاقات الطلبات - Order Cards
   ═══════════════════════════════════════════════════════════════ */

.order-card {
    background: var(--white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-right: 4px solid var(--gray);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.order-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.order-card.new {
    border-color: #3b82f6;
}

.order-card.preparing {
    border-color: #f97316;
}

.order-card.ready {
    border-color: #22c55e;
}

.order-card.delivered {
    border-color: #7c3aed;
    opacity: 0.8;
}

.order-card.cancelled {
    border-color: #ef4444;
    opacity: 0.6;
}

/* New Order Animation */
@keyframes newOrderPulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    50% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
}

.order-card.new-arrival {
    animation: newOrderPulse 1s ease 3;
}

/* Card Header */
.card-header {
    padding: 6px 10px;
    background: #f9f9f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-id {
    font-weight: bold;
    color: var(--primary);
    font-size: 0.95rem;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
}

.status-badge.new {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.preparing {
    background: #ffedd5;
    color: #c2410c;
}

.status-badge.ready {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.delivered {
    background: #f3e8ff;
    color: #7c3aed;
}

.status-badge.cancelled {
    background: #fee2e2;
    color: #dc2626;
}

/* Card Body */
.card-body {
    padding: 8px 10px;
    flex: 1;
}

.customer-info {
    margin-bottom: 4px;
}

.customer-name {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.customer-phone {
    color: #22c55e;
    font-weight: 500;
    font-size: 0.8rem;
}

.customer-phone i {
    margin-left: 4px;
}

.order-type {
    color: var(--gray);
    font-size: 0.8rem;
    margin-bottom: 3px;
}

.order-type i {
    margin-left: 4px;
}

.order-address,
.order-car {
    font-size: 0.78rem;
    color: var(--gray);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-address i,
.order-car i {
    margin-left: 4px;
}

/* حالة التوصيل */
.order-driver-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 6px;
    margin: 3px 0;
    font-size: 0.78rem;
    border: 1px solid #bae6fd;
}

.order-driver-status i {
    color: #0284c7;
}

.driver-name {
    font-weight: 600;
    color: #0369a1;
}

.delivery-status-badge {
    margin-right: auto;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.delivery-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.delivery-status-badge.driver_accepted {
    background: #dbeafe;
    color: #1d4ed8;
}

.delivery-status-badge.picked_up {
    background: #d1fae5;
    color: #065f46;
}

.delivery-status-badge.delivered {
    background: #a7f3d0;
    color: #047857;
}

.order-items {
    padding: 6px 8px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-top: 4px;
    font-size: 0.78rem;
    line-height: 1.3;
}

.order-items::-webkit-scrollbar {
    width: 3px;
}

.order-items::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════════
   الملاحظات - Notes (Text & Voice)
   ═══════════════════════════════════════════════════════════════ */

.order-notes {
    padding: 5px 8px;
    background: #fff3cd;
    border-radius: 6px;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #856404;
    border-right: 3px solid #ffc107;
}

.order-notes strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.82rem;
}

/* مشغل الملاحظة الصوتية */
.voice-note-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.voice-note-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #b45309 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-note-icon i {
    font-size: 1.1rem;
}

.voice-note-player audio {
    flex: 1;
    height: 36px;
    max-width: 300px;
}

.voice-note-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.voice-note-duration {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.voice-note-size {
    font-size: 0.75rem;
    color: #6b7280;
    flex-shrink: 0;
    font-weight: 500;
}

/* رسالة تحميل الصوت */
.audio-loading-msg {
    width: 100%;
    text-align: center;
    padding: 6px 10px;
    margin-top: 8px;
    background: #fef3cd;
    color: #856404;
    border-radius: 6px;
    font-size: 0.82rem;
    animation: fadeIn 0.3s ease;
}

.audio-loading-msg.error {
    background: #f8d7da;
    color: #721c24;
}

.audio-loading-msg i {
    margin-left: 6px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ملاحظات نصية */
.text-notes {
    display: flex;
    gap: 10px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    align-items: flex-start;
}

.text-notes i {
    color: var(--primary);
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.text-notes span {
    color: #111827;
    line-height: 1.5;
    font-size: 0.9rem;
}

/* Card Footer */
.card-footer {
    padding: 6px 10px;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.order-total {
    font-size: 1rem;
    font-weight: bold;
    color: #22c55e;
}

.card-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   الأزرار - Action Buttons
   ═══════════════════════════════════════════════════════════════ */

.btn-action {
    padding: 5px 8px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.btn-action i {
    margin-left: 3px;
}

.btn-next {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #22c55e;
}

.btn-next:hover {
    background: #22c55e;
    color: white;
}

.btn-cancel {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #ef4444;
}

.btn-cancel:hover {
    background: #ef4444;
    color: white;
}

.btn-print {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #6366f1;
    padding: 5px 8px;
}

.btn-print:hover {
    background: #6366f1;
    color: white;
}

.btn-kitchen {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #f59e0b;
    padding: 5px 8px;
}

.btn-kitchen:hover {
    background: #f59e0b;
    color: white;
}

/* ═══════════════════════════════════════════════════════════════
   حالات فارغة وتحميل - Empty States & Loading
   ═══════════════════════════════════════════════════════════════ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.5;
    display: block;
}

.empty-state h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--gray);
    grid-column: 1 / -1;
}

.loading-spinner i {
    margin-left: 10px;
}
