/* ========================================
   FALLBACK STYLES - Базовые стили для работы без Tailwind CSS
   ======================================== */

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

/* Flexbox utilities */
.flex {
    display: flex;
}

.flex-1 {
    flex: 1 1 0%;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.space-x-4 > * + * {
    margin-left: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

/* Grid utilities */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Spacing */
.p-3 {
    padding: 0.75rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.px-6 {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.py-3 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.py-4 {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 2rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.ml-3 {
    margin-left: 0.75rem;
}

.ml-4 {
    margin-left: 1rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mr-3 {
    margin-right: 0.75rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

/* Typography */
.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.font-bold {
    font-weight: 700;
}

.font-semibold {
    font-weight: 600;
}

.font-medium {
    font-weight: 500;
}

.text-white {
    color: #ffffff;
}

.text-gray-200 {
    color: #e5e7eb;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-600 {
    color: #4b5563;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-900 {
    color: #111827;
}

.text-blue-600 {
    color: #2563eb;
}

.text-red-600 {
    color: #dc2626;
}

.text-purple-600 {
    color: #9333ea;
}

/* Background colors */
.bg-white {
    background-color: #ffffff;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-blue-100 {
    background-color: #dbeafe;
}

.bg-red-100 {
    background-color: #fee2e2;
}

.bg-purple-600 {
    background-color: #9333ea;
}

.bg-blue-600 {
    background-color: #2563eb;
}

.bg-purple-700:hover {
    background-color: #7e22ce;
}

.bg-blue-700:hover {
    background-color: #1d4ed8;
}

/* Border and rounded */
.rounded {
    border-radius: 0.25rem;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-full {
    border-radius: 9999px;
}

.border {
    border-width: 1px;
    border-color: #e5e7eb;
}

.border-b {
    border-bottom-width: 1px;
    border-color: #e5e7eb;
}

.shadow {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.shadow-lg {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Layout */
.h-screen {
    height: 100vh;
}

.w-64 {
    width: 16rem;
}

.overflow-hidden {
    overflow: hidden;
}

.overflow-y-auto {
    overflow-y: auto;
}

.overflow-auto {
    overflow: auto;
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

button:hover {
    opacity: 0.9;
}

/* Transitions */
.transition-colors {
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Responsive */
@media (max-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}

/* ========================================
   ORDERS CALENDAR STYLES
   ======================================== */

/* Orders Calendar Styles */
.calendar-container {
    max-height: 60vh;
    overflow: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.calendar-grid {
    display: table;
    width: 100%;
    min-width: max-content;
}

.calendar-row {
    display: table-row;
}

.calendar-cell {
    display: table-cell;
    background: white;
    padding: 8px;
    min-height: 40px;
    min-width: 80px;
    max-width: 80px;
    width: 80px;
    border: 1px solid #e5e7eb;
    vertical-align: middle;
    text-align: center;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
}

.calendar-input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 14px;
    padding: 4px;
    border-radius: 3px;
    min-width: 0;
}

.calendar-input:focus {
    outline: 2px solid #DC143C;
    outline-offset: -2px;
    background: #fef2f2;
}

.depot-cell {
    background: #f9fafb;
    font-weight: 600;
    font-size: 13px;
    text-align: left;
    padding-left: 12px;
    min-width: 150px;
    max-width: 150px;
    width: 150px;
}

.fuel-cell {
    background: #f3f4f6;
    font-weight: 500;
    font-size: 12px;
    text-align: center;
    min-width: 120px;
    max-width: 120px;
    width: 120px;
}

.date-header {
    background: #1f2937;
    color: white;
    font-weight: 600;
    font-size: 10px;
    text-align: center;
    min-width: 60px;
    max-width: 60px;
    width: 60px;
    padding: 4px 2px;
}

.total-cell {
    background: #fef3c7;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    color: #92400e;
    min-width: 80px;
    max-width: 80px;
    width: 80px;
}

.has-value {
    background: #ecfdf5;
}

.has-value .calendar-input {
    font-weight: 600;
    color: #065f46;
}

.fuel-автобензины { border-left: 4px solid #DC143C; }
.fuel-дт { border-left: 4px solid #ef4444; }
.fuel-газ { border-left: 4px solid #10b981; }

/* Animations */
.calendar-input:focus,
.has-value {
    transition: all 0.2s ease-in-out;
}

/* Scrollbars */
.calendar-container::-webkit-scrollbar {
    height: 8px;
}

.calendar-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.calendar-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.calendar-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .calendar-grid {
        font-size: 12px;
    }
    
    .calendar-cell {
        padding: 4px;
        min-height: 35px;
    }
    
    .depot-cell {
        padding-left: 8px;
    }
}

/* ========================================
   OPTIMUS AI ASSISTANT - RED PETROLEUM
   Футуристичный дизайн с эффектами
   ======================================== */

/* Кнопка Optimus */
.ai-assistant-button {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    left: auto !important;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 30px;
    box-shadow: 0 4px 20px rgba(220, 20, 60, 0.4);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: buttonPulse 3s ease-in-out infinite, buttonGlow 2s ease-in-out infinite;
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(220, 20, 60, 0.4),
                    0 0 30px rgba(220, 20, 60, 0.3);
    }
    50% {
        box-shadow: 0 6px 30px rgba(220, 20, 60, 0.6),
                    0 0 40px rgba(220, 20, 60, 0.5);
    }
}

.ai-assistant-button:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 8px 40px rgba(220, 20, 60, 0.6),
                0 0 50px rgba(220, 20, 60, 0.6);
}

.ai-assistant-button:active {
    transform: translateY(-1px) scale(1.05);
}

/* Контейнер чата */
.ai-assistant-container {
    position: fixed !important;
    bottom: 96px !important;
    right: 24px !important;
    left: auto !important;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 540px;
    max-height: calc(100vh - 130px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15),
                0 0 30px rgba(220, 20, 60, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 999;
    overflow: hidden;
    border: 2px solid transparent;
    background-clip: padding-box;
    animation: containerSlideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ai-assistant-container::before {
    content: '';
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    padding: 2px;
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
    z-index: 0;
}

@keyframes containerSlideUp {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    60% {
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Заголовок */
.ai-assistant-header {
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.ai-assistant-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: headerShine 3s ease-in-out infinite;
}

@keyframes headerShine {
    0%, 100% {
        transform: translate(-50%, -50%);
    }
    50% {
        transform: translate(-30%, -30%);
    }
}

.ai-assistant-header h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.ai-assistant-close {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.ai-assistant-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* Область сообщений */
.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-assistant-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-assistant-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-assistant-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    border-radius: 10px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #B22222 0%, #8B0000 100%);
}

/* Сообщения пользователя */
.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #DC143C 0%, #B22222 100%);
    color: white;
    padding: 11px 15px;
    border-radius: 18px 18px 4px 18px;
    max-width: 75%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
    font-size: 14px;
    line-height: 1.5;
    animation: messageSlideIn 0.3s ease-out;
}

/* Сообщения от Optimus */
.ai-message {
    align-self: flex-start;
    background: white;
    color: #1e293b;
    padding: 11px 15px;
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
    word-wrap: break-word;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 14px;
    line-height: 1.6;
    animation: messageSlideIn 0.3s ease-out;
    position: relative;
}

.ai-message::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    border-radius: 18px 0 0 18px;
}

.ai-message strong {
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

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

/* Индикатор "печатает..." */
.typing-indicator {
    align-self: flex-start;
    background: white;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: typingDots 1.4s infinite;
}

.typing-indicator span:nth-child(1) {
    background: #DC143C;
}

.typing-indicator span:nth-child(2) {
    background: #B22222;
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    background: #8B0000;
    animation-delay: 0.4s;
}

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

/* Область ввода */
.ai-assistant-input-container {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.ai-assistant-input-container input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 22px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.ai-assistant-input-container input:focus {
    border-color: transparent;
    background: white;
    box-shadow: 0 0 0 2px rgba(220, 20, 60, 0.2),
                0 0 0 4px rgba(220, 20, 60, 0.1);
}

.ai-assistant-input-container button {
    background: linear-gradient(135deg, #DC143C 0%, #8B0000 100%);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
}

.ai-assistant-input-container button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 4px 16px rgba(220, 20, 60, 0.5),
                0 0 20px rgba(220, 20, 60, 0.3);
}

.ai-assistant-input-container button:active {
    transform: scale(1.05) rotate(10deg);
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .ai-assistant-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        font-size: 28px;
    }
    
    .ai-assistant-container {
        bottom: 88px;
        right: 20px;
        left: 20px;
        width: auto;
        height: 500px;
    }
    
    .ai-assistant-header {
        padding: 16px;
    }
    
    .ai-assistant-header h3 {
        font-size: 17px;
    }
    
    .user-message,
    .ai-message {
        max-width: 85%;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .ai-assistant-container {
        height: 450px;
        bottom: 88px;
    }
    
    .ai-assistant-messages {
        padding: 12px;
    }
    
    .ai-assistant-input-container {
        padding: 12px;
    }
}
