/* ============================================================ */
/* جميع الأنماط                                                 */
/* ============================================================ */
:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --secondary: #f39c12;
    --success: #27ae60;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --card-bg: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.2);
    --ai-primary: #6c5ce7;
    --ai-secondary: #a29bfe;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Cairo', 'Tahoma', sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-container {
    max-width: 1400px;
    width: 100%;
    background: var(--light);
    border-radius: 20px;
    box-shadow: var(--shadow-hover);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #e74c3c 0%, #f39c12 100%);
    padding: 20px;
    text-align: center;
    color: white;
}

.header h1 {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
}

.header p {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    opacity: 0.95;
}

.category-nav {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    background: white;
    overflow-x: auto;
    border-bottom: 2px solid #eee;
    position: sticky;
    top: 0;
    z-index: 100;
}

.category-nav-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: clamp(0.75rem, 1.5vw, 0.9rem);
    transition: all 0.3s;
    white-space: nowrap;
    color: #333;
    flex-shrink: 0;
}

.category-nav-btn:hover {
    background: #e0e0e0;
}

.category-nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 15px;
}

@media (min-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr 420px;
        padding: 25px;
    }
}

.menu-section {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 15px;
    box-shadow: var(--shadow);
}

/* ===== الأقسام - تظهر كلها ===== */
.category-section {
    margin-bottom: 25px;
    display: block !important;
}

.category-section.hidden {
    display: none !important;
}

.category-title {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 15px;
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9f9f9;
    border-right: 4px solid var(--primary);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }
}

.menu-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s;
}

.menu-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.item-image {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
}

.item-name {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 3px;
}

.item-unit-price {
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 900;
    color: var(--primary);
}

.item-unit-price span {
    font-size: 0.8rem;
    color: #999;
    font-weight: 400;
}

.quantity-selector {
    margin: 10px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quantity-input {
    width: 70px;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
    font-weight: 700;
}

.quantity-unit {
    color: #666;
    font-weight: 600;
    font-size: 0.9rem;
}

.total-item-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--success);
    margin-right: auto;
}

.quick-quantity-btns {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.quick-qty-btn {
    padding: 4px 10px;
    background: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.quick-qty-btn:hover {
    background: var(--secondary);
    color: white;
}

.add-to-cart-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #e74c3c 0%, #f39c12 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
}

.add-to-cart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.cart-section {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: var(--shadow);
    position: relative;
}

@media (min-width: 1024px) {
    .cart-section {
        position: sticky;
        top: 80px;
        height: fit-content;
        max-height: 90vh;
        overflow-y: auto;
    }
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.cart-title {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    font-weight: 800;
    color: var(--dark);
}

.cart-count {
    background: var(--primary);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.9rem;
}

#cart-items {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

#cart-items li {
    background: #f9f9f9;
    margin: 8px 0;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    font-size: 0.9rem;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.cart-item-name {
    font-weight: 700;
    color: var(--dark);
}

.cart-item-price {
    font-weight: 800;
    color: var(--primary);
}

.cart-item-details {
    font-size: 0.8rem;
    color: #666;
    margin-top: 3px;
}

.remove-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.75rem;
}

.shops-input-area {
    margin: 10px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.shops-input-area .shop-entry {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.shops-input-area .shop-entry input {
    flex: 1;
    padding: 7px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.8rem;
    min-width: 100px;
}

.shops-input-area .shop-entry input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.shops-input-area .shop-entry .shop-name-input {
    flex: 2;
}

.shops-input-area .shop-entry .shop-zone-input {
    flex: 1;
    min-width: 70px;
}

.shops-input-area .shop-entry .remove-shop {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shops-input-area .shop-entry .remove-shop:hover {
    background: var(--primary-dark);
}

.shops-input-area .shop-entry .shop-number {
    font-weight: 700;
    color: var(--dark);
    font-size: 0.75rem;
    min-width: 18px;
}

.add-shop-btn {
    padding: 5px 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.7rem;
    transition: all 0.3s;
    margin-top: 4px;
}

.add-shop-btn:hover {
    background: #5a6268;
    transform: scale(1.02);
}

.shops-label {
    font-weight: 700;
    color: #555;
    font-size: 0.85rem;
    display: block;
    margin-bottom: 6px;
}

.shops-label small {
    font-weight: 400;
    color: #888;
    font-size: 0.7rem;
}

.total-section {
    text-align: center;
    padding: 12px 0;
    border-top: 2px solid #eee;
}

.total-price {
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    font-weight: 900;
    color: var(--primary);
    margin: 3px 0;
}

.delivery-fee {
    font-size: 0.8rem;
    color: #666;
}

.delivery-alert {
    margin-top: 6px;
    padding: 8px 10px;
    background: #fdecea;
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.user-form {
    margin-top: 12px;
}

.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: 700;
    color: #555;
    font-size: 0.85rem;
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.3s;
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-input.loading {
    background: #f0f8ff;
    border-color: #1a73e8;
    color: #1a73e8;
}

.form-input.success {
    background: #e8f5e9;
    border-color: #27ae60;
    color: #2e7d32;
}

.form-input.error {
    background: #ffebee;
    border-color: #e74c3c;
    color: #c62828;
}

.form-input:disabled {
    opacity: 0.8;
    cursor: default;
}

.submit-order-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 12px;
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

.submit-order-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.6);
}

.submit-order-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fees-info {
    margin-top: 8px;
    padding: 8px;
    background: #f0f8ff;
    border-radius: 8px;
    font-size: 0.7rem;
    color: #555;
}

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

.shop-list {
    font-size: 0.75rem;
    color: #555;
    margin: 5px 0;
    padding: 5px 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

.shop-list .shop-item {
    display: inline-block;
    background: #e8f0fe;
    color: #1a73e8;
    padding: 1px 10px;
    border-radius: 10px;
    margin: 2px 3px;
    font-size: 0.65rem;
}

.location-status {
    font-size: 0.65rem;
    color: #666;
    margin-top: 3px;
    padding: 3px 8px;
    background: #f5f5f5;
    border-radius: 6px;
}

.location-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 5px;
    width: 100%;
}

.location-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 115, 232, 0.4);
}

.location-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 350px;
    width: 100%;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.toast-success {
    background: #27ae60;
}

.toast-error {
    background: #dc3545;
}

.toast-warning {
    background: #856404;
}

.toast-info {
    background: #17a2b8;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: auto;
    padding: 0 4px;
    opacity: 0.8;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================ */
/* AI ASSISTANT                                                  */
/* ============================================================ */
.ai-assistant-toggle {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
    color: white;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.5);
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(108, 92, 231, 0.7);
}

.ai-assistant-toggle .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #27ae60;
    border-radius: 50%;
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.ai-chat-window {
    position: fixed;
    bottom: 110px;
    left: 30px;
    width: 380px;
    max-width: calc(100vw - 60px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    border: 1px solid rgba(108, 92, 231, 0.2);
    animation: slideUp 0.3s ease;
}

.ai-chat-window.open {
    display: flex;
}

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

.ai-chat-header {
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-chat-header .title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1rem;
}

.ai-chat-header .title .status {
    width: 8px;
    height: 8px;
    background: #27ae60;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

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

.ai-chat-header .close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.ai-chat-header .close-btn:hover {
    background: rgba(255,255,255,0.3);
}

.ai-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
}

.ai-chat-messages .message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.6;
    animation: messageIn 0.3s ease;
}

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

.ai-chat-messages .message.user {
    background: var(--ai-primary);
    color: white;
    margin-left: auto;
    border-bottom-left-radius: 4px;
}

.ai-chat-messages .message.assistant {
    background: white;
    color: var(--dark);
    border: 1px solid #e0e0e0;
    border-bottom-right-radius: 4px;
}

.ai-chat-messages .message.assistant .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.ai-chat-messages .message.assistant .typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--ai-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.ai-chat-messages .message.assistant .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-messages .message.assistant .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

.ai-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.ai-chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s;
    background: #f8f9fa;
}

.ai-chat-input-area input:focus {
    border-color: var(--ai-primary);
    background: white;
}

.ai-chat-input-area button {
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.ai-chat-input-area button:hover {
    transform: scale(1.05);
}

.ai-chat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-footer {
    padding: 8px 15px;
    font-size: 0.6rem;
    color: #999;
    text-align: center;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: white;
}

.quick-suggestions {
    display: flex;
    gap: 6px;
    padding: 8px 15px;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.quick-suggestions button {
    padding: 4px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
    color: #555;
}

.quick-suggestions button:hover {
    background: var(--ai-primary);
    color: white;
    border-color: var(--ai-primary);
}

@media (max-width: 480px) {
    .ai-chat-window {
        bottom: 90px;
        left: 10px;
        width: calc(100vw - 20px);
        height: calc(100vh - 160px);
        max-height: calc(100vh - 160px);
        border-radius: 15px;
    }
    .ai-assistant-toggle {
        bottom: 20px;
        left: 20px;
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
}
