/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-all: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color, #f8fafc);
    color: var(--tg-theme-text-color, #1e293b);
    line-height: 1.6;
    padding: 0;
    margin: 0;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: var(--primary-gradient);
    z-index: -1;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

header {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '📄';
    position: absolute;
    font-size: 80px;
    opacity: 0.1;
    top: -20px;
    right: -20px;
    transform: rotate(-15deg);
}

h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
    position: relative;
}

.subtitle {
    font-size: 16px;
    color: #64748b;
    font-weight: 400;
}

h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}

h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

/* Секции формы */
.form-section {
    background: white;
    padding: 28px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    transition: var(--transition-all);
    position: relative;
}

/* Список ожиданий */
.pending-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pending-item {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.pending-item-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.amount-light {
    font-weight: 500;
    color: #475569;
}

.pending-item-meta {
    font-size: 13px;
    color: #64748b;
}

.pending-item button {
    margin-top: 8px;
}

.org-info-card {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 14px;
}

.member-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.member-meta {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
}

.btn-small {
    padding: 7px 10px;
    font-size: 12px;
    min-width: 96px;
}

.pending-details {
    margin-top: 12px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.timeline-list {
    margin: 8px 0 0 18px;
    padding: 0;
}

.timeline-list li {
    margin-bottom: 4px;
    color: #475569;
    font-size: 14px;
}

.workflow-step-row {
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 10px;
    background: #f8fafc;
}

.workflow-step-row.invalid {
    border-color: #ef4444;
    background: #fff1f2;
}

.workflow-step-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
}

.workflow-card-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: #dcfce7;
    color: #166534;
}

.form-section:hover {
    box-shadow: var(--shadow-lg);
}

/* Группы полей */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #475569;
    font-size: 14px;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.required {
    color: var(--danger-color);
    font-weight: 700;
}

/* Поля ввода */
input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    background: white;
    color: #1e293b;
    transition: var(--transition-all);
    font-weight: 500;
}

input[type="text"]:hover,
input[type="number"]:hover,
textarea:hover,
select:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

/* Добавим плейсхолдеры */
input::placeholder,
textarea::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* Загрузка файлов */
.file-upload-wrapper {
    position: relative;
    margin-bottom: 16px;
}

input[type="file"] {
    display: none;
}

#contractFiles {
    display: block;
    width: 100%;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
}

.file-upload-label {
    display: block;
    padding: 20px;
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    cursor: pointer;
    text-align: center;
    transition: var(--transition-all);
    position: relative;
    overflow: hidden;
}

.file-upload-label::before {
    content: '📎';
    display: block;
    font-size: 32px;
    margin-bottom: 8px;
}

.file-upload-label:hover {
    border-color: #667eea;
    background: #f1f5f9;
    transform: translateY(-2px);
}

.file-upload-wrapper:has(input[type="file"]:focus) .file-upload-label {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.file-upload-text {
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.file-upload-hint {
    font-size: 14px;
    color: #94a3b8;
}

.file-info {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    font-size: 14px;
    color: #166534;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease-out;
}

.file-info::before {
    content: '✓';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

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

/* Список приложений */
#attachmentsList {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

.attachment-item input[type="file"] {
    flex: 1;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.remove-attachment {
    margin-left: auto;
    padding: 8px 16px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition-all);
}

.remove-attachment:hover {
    background: #fecaca;
    border-color: #f87171;
    transform: scale(1.05);
}

/* Кнопки */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-all);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(102, 126, 234, 0.4);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(102, 126, 234, 0.5);
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px 0 rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    font-weight: 600;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px 0 rgba(102, 126, 234, 0.3);
}

.btn-secondary:active {
    transform: translateY(0);
}

#addAttachment {
    width: auto;
    padding: 10px 20px;
    font-size: 13px;
    background: #f0f9ff;
    color: #0369a1;
    border: 2px solid #0284c7;
}

#addAttachment:hover {
    background: #0284c7;
    color: white;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* Индикатор загрузки */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.spinner {
    width: 64px;
    height: 64px;
    position: relative;
}

.spinner::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.spinner::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    margin-top: 16px;
    font-size: 16px;
    color: #f0f0f0;
}

/* Стили для кастомного уведомления */
.custom-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
}

.custom-alert.show {
    opacity: 1;
    visibility: visible;
}

.custom-alert.error {
    background-color: #dc3545;
}

/* Прогресс-бар */
.progress-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    padding: 0 20px;
}

.progress-step {
    flex: 1;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    position: relative;
    transition: var(--transition-all);
}

.progress-step.active {
    background: var(--primary-gradient);
}

.progress-step.completed {
    background: var(--success-color);
}

/* Подсказки и валидация */
.input-hint {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
}

.input-error {
    font-size: 13px;
    color: var(--danger-color);
    margin-top: 6px;
    display: none;
}

.form-group.error input,
.form-group.error textarea,
.form-group.error select {
    border-color: var(--danger-color);
}

.form-group.error .input-error {
    display: block;
}

/* Адаптивность */
@media (max-width: 640px) {
    body::before {
        height: 150px;
    }
    
    .container {
        padding: 16px;
    }
    
    header {
        padding: 24px 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .form-section {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 10px 18px;
    }
    
    input[type="text"],
    input[type="number"],
    textarea {
        font-size: 16px; /* Предотвращает zoom на iOS */
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    body {
        background-color: #0f172a;
    }
    
    header {
        background: #1e293b;
        color: white;
    }
    
    h1 {
        color: white;
    }
    
    .subtitle {
        color: #94a3b8;
    }
    
    .form-section {
        background: #1e293b;
    }
    
    h2 {
        color: #e2e8f0;
    }
    
    label {
        color: #cbd5e1;
    }
    
    input[type="text"],
    input[type="number"],
    textarea {
        background: #1e293b;
        border-color: #334155;
        color: white;
    }
    
    .file-upload-label {
        background: #0f172a;
        border-color: #334155;
    }
}
