/* Оформление конкретных экранов админки: карточки автоматов, сетка ячеек,
   модальные окна. */
/* Machines Cards Grid */
.machines-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

@media (max-width: 900px) {
    .machines-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.machine-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.2s ease;
}

/* Имя автомата раньше красилось инлайновым color:#fff прямо в admin-machines.js.
   На светлой теме карточка розовая (#FFEFF7), и белый по ней не читался вовсе.
   Цвет берётся из темы, а не вшивается в разметку. */
.machine-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.machine-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(236, 72, 153, 0.08);
    transform: translateY(-2px);
}

/* Visual Lockers Grid */
.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--card-border);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 24px;
}

.locker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}


.locker-cell {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 190px;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    
}

.locker-cell.occupied.available {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.03);
}

.locker-cell.occupied.available:hover {
    border-color: var(--success);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.15);
}

.locker-cell.occupied.sold {
    background: rgba(239, 68, 68, 0.04);
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 8px 16px rgba(239, 68, 68, 0.03);
    opacity: 0.85;
}

.locker-cell.occupied.sold:hover {
    border-color: var(--error);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.15);
}

.locker-cell.empty {
    border-style: dashed;
    border-width: 2px;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
}

.locker-cell.empty:hover {
    border-color: var(--primary);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.locker-cell-header {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 2;
    gap: 4px;
}

.locker-num {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.locker-status-badge {
    font-size: 10px;
    text-align: center;
    flex-shrink: 1;
    min-width: 0;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

.locker-num.active-num {
    color: var(--secondary);
}

.locker-content {
    margin-top: 18px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.locker-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.locker-price {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.locker-qr-id {
    font-size: 11px;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
    color: #a78bfa;
    margin-bottom: 12px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
    text-align: left;
}

.locker-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.add-icon {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-muted);
    margin-bottom: 6px;
    transition: color 0.2s;
}

.locker-cell.empty:hover .add-icon {
    color: var(--primary);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.dispensed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 480px;
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .modal {
        padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    }
    
    .modal-content {
        padding: 16px;
        max-width: 100%;
        margin-top: 0;
    }

    .modal-form {
        flex-direction: column;
    }
    
    .modal-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .modal-actions .btn,
    .modal-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .locker-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .locker-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .locker-cell {
        min-height: 120px;
        padding: 8px;
    }
    .locker-cell-header {
        position: relative;
        top: 0;
        left: 0;
        right: 0;
        flex-wrap: wrap;
    }
    .locker-num {
        font-size: 10px;
    }
    .locker-title {
        font-size: 12px;
        margin-bottom: 2px;
    }
    .locker-price {
        font-size: 10px;
        margin-bottom: 4px;
    }
    .locker-qr-id {
        font-size: 9px;
        padding: 1px 4px;
        margin-bottom: 6px;
    }
    .add-icon {
        font-size: 20px;
    }
}

/* Task 2: Tab scroll hints */
.tabs-wrapper::before,
.tabs-wrapper::after {
    content: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30px;
    pointer-events: none;
}
.tabs-wrapper::before {
    left: 0;
    background: linear-gradient(to right, var(--bg-dark), transparent);
    border-radius: 14px 0 0 14px;
}
.tabs-wrapper::after {
    right: 0;
    background: linear-gradient(to left, var(--bg-dark), transparent);
    border-radius: 0 14px 14px 0;
}
.tabs-wrapper.can-scroll-left::before {
    content: '';
}
.tabs-wrapper.can-scroll-right::after {
    content: '';
}

/* Task 3: Header compactness for mobile */
@media (max-width: 480px) {
    .header {
        flex-wrap: wrap !important;
    }
    .header > div:first-child {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    .header > div:last-child {
        width: 100%;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 4px;
    }
    .header-title {
        font-size: 11px;
        margin-top: 0;
        margin-left: auto;
    }
    .header .btn {
        padding: 4px 8px !important;
        font-size: 11px !important;
        white-space: nowrap;
    }
    .status-badge {
        padding: 4px 6px;
        font-size: 10px;
        white-space: nowrap;
    }
}
