/**
 * GIPIX CRM — мобильные карточки записей (.mobile-appointments-container, .appointment-card).
 * Подключается из base.html после components-clients.css.
 */

/* === МОБИЛЬНЫЕ КАРТОЧКИ ЗАПИСЕЙ === */
.mobile-appointments-container {
    display: none;
}

@media (max-width: 768px) {
    /* Скрываем таблицу на мобильных */
    .table-responsive {
        display: none !important;
    }
    
    /* Показываем контейнер с карточками */
    .mobile-appointments-container {
        display: block;
    }
}

.appointment-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* transform на hover ломает position:fixed у выпадающих меню внутри карточки на тач-устройствах */
@media (hover: hover) and (pointer: fine) {
    .appointment-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}

.appointment-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--md-primary);
}

/* Статусные полоски */
.appointment-card.past-date::before { background: #6c757d; }
.appointment-card.today-date::before { background: #dc3545; }
.appointment-card.future-date::before { background: #28a745; }

.appointment-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.appointment-card-date-time {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 80px;
}

/* Дата/время только в карточке — не перебивать .datetime-cell таблицы (style.css) */
.appointment-card .appointment-card-date-time .appointment-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    line-height: 1.2;
}

.appointment-card .appointment-card-date-time .appointment-time {
    background: var(--md-info);
    color: #fff;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    line-height: 1;
}

.appointment-card-id {
    background: var(--md-gray-100);
    color: var(--md-gray-600);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    align-self: flex-start;
}

.appointment-card-body {
    margin-bottom: 12px;
}

.appointment-client-info {
    margin-bottom: 8px;
}

.appointment-client-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.appointment-client-avatar-mobile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.avatar-image-mobile {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.client-avatar-fallback-mobile {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--md-primary), var(--md-primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

.appointment-client-avatar-mobile .client-avatar-fallback-mobile {
    display: none;
}

.appointment-client-details {
    flex: 1;
    min-width: 0;
}

.appointment-client-name-link {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
    line-height: 1.3;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
}

.appointment-client-name-link:hover {
    color: var(--md-primary);
    text-decoration: none;
}

.appointment-client-phone {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6c757d;
    font-size: 0.9rem;
    text-decoration: none;
}

.appointment-client-phone:hover {
    color: #28a745;
    text-decoration: none;
}

.appointment-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.appointment-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.appointment-detail-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.appointment-detail-value {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
    line-height: 1.3;
}

.appointment-master-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--md-gray-50);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.appointment-master-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.appointment-master-icon.mech { background: var(--md-primary); }
.appointment-master-icon.body { background: var(--md-accent); }
.appointment-master-icon.electric { background: var(--md-warning); }
.appointment-master-icon.tyre { background: var(--md-secondary-dark); }
.appointment-master-icon.diagnostic { background: var(--md-success); }

.appointment-master-icon--unassigned {
    background: #6c757d;
}

.appointment-master-details {
    flex: 1;
    min-width: 0;
}

.appointment-master-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
    line-height: 1.2;
}

.appointment-master-shop {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.appointment-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.appointment-price-time {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.appointment-price {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--md-success);
}

.appointment-time-left {
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
}

.appointment-time-left.soon {
    background: rgba(255, 193, 7, 0.2);
    color: #856404;
}

.appointment-time-left.now {
    background: rgba(220, 53, 69, 0.2);
    color: #721c24;
    animation: pulse 2s infinite;
}

.appointment-time-left.later {
    background: rgba(40, 167, 69, 0.2);
    color: #155724;
}

.appointment-time-left.passed {
    background: rgba(108, 117, 125, 0.2);
    color: #6c757d;
}

.appointment-actions {
    display: flex;
    gap: 6px;
}

.appointment-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
    color: #6c757d;
}

.appointment-action-btn:hover {
    color: #fff;
    text-decoration: none;
    transform: scale(1.05);
}

.appointment-action-btn.edit:hover {
    background: var(--md-warning);
    border-color: var(--md-warning);
}

.appointment-action-btn.history:hover {
    background: var(--md-info);
    border-color: var(--md-info);
}

.appointment-action-btn.payment:hover {
    background: var(--md-success);
    border-color: var(--md-success);
}

.appointment-action-btn.delete:hover {
    background: var(--md-danger);
    border-color: var(--md-danger);
}

.appointment-action-btn .material-icons {
    font-size: 18px;
}

/* Компактная версия карточки для списка */
.appointment-card.compact {
    padding: 12px;
    margin-bottom: 8px;
}

.appointment-card.compact .appointment-card-header {
    margin-bottom: 8px;
}

.appointment-card.compact .appointment-client-name-link {
    font-size: 1rem;
}

.appointment-card.compact .appointment-client-avatar-mobile {
    width: 32px;
    height: 32px;
}

.appointment-card.compact .client-avatar-fallback-mobile {
    font-size: 12px;
}

.appointment-card.compact .appointment-master-info {
    padding: 8px 10px;
    margin-bottom: 8px;
}

.appointment-card.compact .appointment-master-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

/* Анимации */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.appointment-card {
    animation: slideInFromRight 0.3s ease-out;
}

.appointment-card:nth-child(2) { animation-delay: 0.1s; }
.appointment-card:nth-child(3) { animation-delay: 0.2s; }
.appointment-card:nth-child(4) { animation-delay: 0.3s; }
.appointment-card:nth-child(5) { animation-delay: 0.4s; }

/* Улучшения для пустого состояния */
.no-appointments-mobile {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.no-appointments-mobile .material-icons {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-appointments-mobile h5 {
    margin-bottom: 8px;
    color: #495057;
}

.no-appointments-mobile p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* Стили для фильтрации */
.mobile-appointments-container .appointment-card[style*="display: none"] {
    display: none !important;
}

/* Загрузчик для мобильных карточек */
.mobile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #6c757d;
}

.mobile-loading .loading-spinner {
    border-color: var(--md-gray-300);
    border-top-color: var(--md-primary);
}
