/* === COMPONENTS.CSS ===
 * /serverflow/assets/css/components.css
 * НАЗНАЧЕНИЕ: Стили всех UI компонентов системы ServerFlow
 * ВКЛЮЧАЕТ: Кнопки, формы, карточки, модальные окна, таблицы, алерты, спиннеры
 * РАЗМЕР: ~450 строк
 * ОБНОВЛЕНО: 2025-01-02
 * 
 * СТРУКТУРА ФАЙЛА:
 * 1. Buttons (строки 20-100)
 * 2. Forms (строки 101-200)
 * 3. Cards (строки 201-250)
 * 4. Modals (строки 251-350)
 * 5. Tables (строки 351-400)
 * 6. Alerts & Badges (строки 401-450)
 * 7. Spinners & Tooltips (строки 451-500)
 */

/* === BUTTONS === */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.5);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--ai-blue);
    background: rgba(59, 130, 246, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.5);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.5);
}

.btn-payment {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
}

.btn-payment:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(59, 130, 246, 0.5);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 40px;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 56px;
}

.btn-icon {
    padding: 0.75rem;
    min-width: 48px;
}

/* === FORMS === */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--ai-gray);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--ai-blue);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #666;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23a3a3a3' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.form-checkbox,
.form-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"],
.form-radio input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.form-link {
    color: var(--ai-blue);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.form-link:hover {
    color: var(--ai-purple);
    text-decoration: underline;
}

/* === CARDS === */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--ai-blue);
    box-shadow: 0 20px 40px rgba(59, 130, 246, 0.1);
}

.card-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.card-body {
    margin: 1.5rem 0;
}

.card-description {
    color: var(--text-muted);
    line-height: 1.6;
}

.card-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* === MODALS === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.modal.active {
    display: block;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    animation: slideUp 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    transform: rotate(90deg);
}

.modal-title {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 2rem;
}

.modal-body {
    margin: 1.5rem 0;
}

.modal-footer {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--ai-gray);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--ai-green);
}

.badge-primary {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--ai-blue);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

/* === TABLES === */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--card-bg);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--ai-gray);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: rgba(59, 130, 246, 0.02);
}

.table-striped tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

/* === ALERTS === */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--ai-green);
}

.alert-error,
.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--ai-blue);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.alert-dismissible {
    position: relative;
    padding-right: 3rem;
}

.alert-close {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1.25rem;
    transition: opacity 0.3s ease;
}

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

/* === SPINNERS === */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--ai-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

.spinner-white {
    border-color: rgba(255,255,255,0.2);
    border-top-color: white;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === TOOLTIPS === */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip-content {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ai-gray);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--ai-gray) transparent transparent transparent;
}

.tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* === UTILITIES === */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--ai-blue); }
.text-success { color: var(--ai-green); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.w-100 { width: 100%; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 2rem;
    }
    
    .btn {
        padding: 0.875rem 1.25rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px; /* Предотвращает zoom на iOS */
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 1.5rem;
    }
    
    .card {
        padding: 1rem;
        border-radius: 16px;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* === PRINT STYLES === */
@media print {
    .modal,
    .btn,
    .form-input,
    .form-select {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
