/* device_form.css - обновленные стили для формы добавления устройства */

/* Сетка формы */
.form-sections-horizontal {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

@media (max-width: 1200px) {
    .form-sections-horizontal {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .form-sections-horizontal {
        grid-template-columns: 1fr;
    }
}

/* Кнопки отправки формы - скрыты */
.form-actions-top {
    display: none !important;
}

/* Стили для кнопки истории в форме */
.client-name-container {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.client-name-container input {
    flex: 1;
}

#client-history-btn,
.client-history-btn {
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 11px;
    padding: 5px 8px;
    height: 28px;
}

#client-history-btn:hover,
.client-history-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Стили для таблицы истории */
.device-row {
    transition: background-color 0.2s ease;
}

.device-row:hover {
    background-color: var(--surface-alt);
    cursor: pointer;
}

/* Обновленные стили для полей телефона - ГОРИЗОНТАЛЬНОЕ РАСПОЛОЖЕНИЕ */
#phones-container {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Уменьшено расстояние между группами телефонов */
}

.phone-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px; /* Уменьшен вертикальный padding */
    background: var(--surface);
    border: 1px solid var(--border-color); /* Более тонкая граница */
    border-radius: 4px;
    margin-bottom: 4px; /* Уменьшен отступ снизу */
    transition: all 0.3s ease;
}

.phone-input-group.primary {
    border-color: var(--text-color);
    background: var(--surface-alt);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.phone-input-group:hover {
    border-color: #cbd6e2;
}

.phone-inputs-row {
    display: flex;
    flex: 1;
    gap: 8px;
    min-width: 0;
}

.phone-input {
    flex: 0 0 180px;
    min-width: 140px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: var(--surface);
    transition: all 0.2s;
    height: 28px;
}

.phone-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.phone-comment {
    flex: 1;
    min-width: 100px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: var(--surface);
    transition: all 0.2s;
    height: 28px;
}

.phone-comment:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.phone-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

/* ОБНОВЛЕННЫЙ ДИЗАЙН КНОПКИ ОСНОВНОГО НОМЕРА - СТРОГИЙ И МИНИМАЛИСТИЧНЫЙ */
.btn-set-primary {
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--border-color);
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.btn-set-primary:hover:not(.active) {
    border-color: var(--text-muted);
    background: var(--surface-alt);
}

.btn-set-primary.active {
    border-color: var(--text-color);
    background: var(--text-muted);
}

.primary-indicator {
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-set-primary:not(.active) .primary-indicator::before {
    content: "";
    width: 6px;
    height: 6px;
    border: 1.5px solid #adb5bd;
    border-radius: 1px;
    background: transparent;
    transition: all 0.2s ease;
}

.btn-set-primary.active .primary-indicator::before {
    content: "✓";
    color: white;
    font-size: 8px;
    font-weight: bold;
    width: 10px;
    height: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
}

/* Кнопка удаления телефона */
.btn-remove-phone {
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--border-color);
    background: transparent;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.btn-remove-phone:hover {
    border-color: #dc3545;
    background: var(--surface-alt);
}

.remove-indicator::before,
.remove-indicator::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 1.5px;
    background: var(--text-muted);
    transition: all 0.2s ease;
}

.remove-indicator::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.remove-indicator::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.btn-remove-phone:hover .remove-indicator::before,
.btn-remove-phone:hover .remove-indicator::after {
    background: #dc3545;
}

/* КОМПАКТНЫЕ ПОЛЯ ВВОДА - уменьшены на 15% */
.compact-input {
    width: 100%;
    padding: 5px 8px !important;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: var(--surface);
    transition: border-color 0.2s;
    height: 28px;
    box-sizing: border-box;
}

.compact-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* КНОПКИ ШАБЛОНОВ - НАД ПОЛЕМ (обновленный дизайн) */
.template-field {
    margin-bottom: 10px;
}

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

.template-header label {
    margin-bottom: 0;
    font-size: 12px;
    font-weight: 600;
}

.btn-template-header {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22.8px;
    width: 160px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

.btn-template-header:hover {
    background: rgba(248, 249, 250, 0.95);
    border-color: var(--text-muted);
    color: var(--text-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-template-header:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.template-field textarea {
    width: 100%;
    padding: 6px 8px !important;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    resize: vertical;
    transition: all 0.2s;
    min-height: 50px;
}

.template-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* ГОРИЗОНТАЛЬНОЕ РАСПОЛОЖЕНИЕ КНОПОК IMEI */
.input-with-buttons-horizontal {
    display: flex;
    gap: 6px;
    align-items: center;
    min-height: 28px;
}

.input-with-buttons-horizontal .compact-input {
    flex: 1;
}

.button-group-horizontal {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.button-group-horizontal .btn {
    padding: 5px 8px;
    font-size: 11px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* СЕКЦИЯ ЗАПЧАСТЕЙ - ПОД ПОЛЕМ СТАТУСА */
.parts-subsection {
    margin-top: 12px;
    padding: 12px;
    background: var(--input-focus-ring);
    border: 2px solid var(--warning-color);
    border-radius: 6px;
    animation: slideDown 0.3s ease-out;
}

.parts-subsection h4 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #856404;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стили для автодополнения клиентов */
.autocomplete-suggestions {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 350px;
    overflow-y: auto;
    width: 450px;
    animation: fadeIn 0.2s ease-in-out;
}

.autocomplete-item {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--surface-alt);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.suggestion-main {
    width: 100%;
}

.client-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.client-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-color);
    flex: 1;
}

.client-orders {
    background: var(--text-muted);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 500;
    margin-left: 6px;
}

.client-phones-section {
    margin-bottom: 6px;
}

/* Улучшаем отображение телефонов с комментариями */
.client-phone-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    padding: 4px 0;
    border-bottom: 1px dashed #f0f0f0;
}

.client-phone-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.phone-number {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-color);
    font-weight: 500;
    min-width: 110px;
}

.phone-comment-badge {
    background: #e3f2fd;
    color: #1976d2;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 500;
    border: 1px solid #bbdefb;
}

.phone-primary-badge {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 500;
    border: 1px solid #c8e6c9;
}

.no-phones {
    color: var(--text-muted);
    font-style: italic;
    font-size: 10px;
    padding: 6px 0;
}

.client-notes {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #e9ecef;
    background: var(--surface-alt);
    padding: 6px;
    border-radius: 3px;
}

/* Улучшаем видимость подсветки совпадений */
.highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
    color: #856404;
}

.autocomplete-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    background: var(--surface-alt);
    border-radius: 4px;
    margin: 6px;
}

/* Стили для улучшенного модального окна IMEI */
.imei-modal {
    max-width: 450px;
}

.imei-info {
    background: var(--surface-alt);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    border-left: 4px solid #007bff;
}

.imei-display {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.imei-value {
    font-family: 'Courier New', monospace;
    background: var(--surface-hover);
    padding: 3px 6px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 11px;
}

.copied-badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

.websites-section h4 {
    margin-bottom: 10px;
    color: var(--text-color);
    font-size: 13px;
}

.website-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    transition: all 0.2s;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 6px;
}

.website-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.website-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.website-info {
    flex: 1;
    min-width: 0;
}

.website-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
    font-size: 12px;
}

.website-url {
    font-size: 10px;
    color: var(--text-muted);
    word-break: break-all;
}

.website-arrow {
    color: var(--text-muted);
    font-size: 11px;
    flex-shrink: 0;
}

.website-item:hover .website-arrow {
    color: var(--primary-color);
}

/* ИСПРАВЛЕННЫЕ СТИЛИ ДЛЯ ГРАФИЧЕСКОГО КЛЮЧА */
.graphical-key-grid {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto 15px;
    background: var(--surface-alt);
    border-radius: 12px;
    border: 3px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 15px;
    padding: 25px;
    box-sizing: border-box;
    touch-action: none;
    place-items: center;
}

.key-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 3px solid var(--dark-color);
    position: relative;
    z-index: 2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    user-select: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-dot span {
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    pointer-events: none;
}

.key-dot.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: scale(1.2);
    box-shadow: 0 4px 8px var(--input-focus-ring);
    animation: dotActivate 0.3s ease-out;
}

.key-dot.visited {
    background: var(--success-color);
    border-color: var(--success-color);
    transform: scale(1.1);
}

.key-dot:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

#key-canvas,
#preview-key-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.key-sequence-display {
    background: var(--surface-hover);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    margin-top: 15px;
}

.sequence-info {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sequence-value {
    font-family: 'Courier New', monospace;
    background: var(--surface);
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    color: var(--text-color);
    font-size: 14px;
    border: 1px solid var(--border-color);
    min-width: 120px;
    text-align: center;
}

.sequence-value.has-value {
    color: #28a745;
    background: var(--surface);
    border-color: #28a745;
}

.sequence-hint {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

@keyframes dotActivate {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1.2); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .phone-input-group {
        flex-direction: column;
        gap: 6px;
    }
    
    .phone-input {
        flex: 1;
        min-width: auto;
    }
    
    .phone-comment {
        flex: 1;
        min-width: auto;
    }
    
    .autocomplete-suggestions {
        width: 95vw !important;
        left: 2.5vw !important;
        right: 2.5vw !important;
        max-width: none;
    }
    
    .client-name-container {
        flex-direction: column;
        gap: 6px;
    }
    
    .client-history-btn {
        align-self: flex-start;
    }

    .input-with-buttons-horizontal {
        flex-direction: column;
        gap: 6px;
    }

    .button-group-horizontal {
        width: 100%;
        justify-content: stretch;
    }

    .button-group-horizontal .btn {
        flex: 1;
    }

    .template-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .btn-template-header {
        align-self: flex-start;
    }

    .graphical-key-grid {
        width: 240px;
        height: 240px;
        gap: 12px;
        padding: 20px;
    }

    .key-dot {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .btn-set-primary {
        width: 26px;
        height: 26px;
    }
    
    .primary-indicator {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .graphical-key-grid {
        width: 220px;
        height: 220px;
    }
    
    .key-dot {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }
    
    .sequence-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}