/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #1a3a52;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Шапка */
header {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1em;
}

/* Экраны */
.screen {
    display: none;
    animation: fadeIn 0.3s;
}

.screen.active {
    display: block;
}

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

/* Контейнер авторизации */
.auth-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    max-width: 500px;
    margin: 40px auto;
    padding: 40px;
}

/* Табы (Auth) */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-button {
    flex: 1;
    padding: 12px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.tab-button.active {
    background: #667eea;
    color: white;
}

.tab-button:hover {
    background: #5568d3;
    color: white;
}

/* Контент табов */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

.tab-content h2 {
    margin-bottom: 20px;
    color: #333;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Кнопки */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:not(:disabled):hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    width: 100%;
}

/* Сообщения */
.message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    display: none;
}

.message.show {
    display: block;
    animation: fadeIn 0.3s;
}

.message.error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.message.success {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

/* Навигация приложения */
.app-nav {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-button {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.nav-button.active {
    background: #667eea;
    color: white;
}

.nav-button:hover {
    background: #f0f0f0;
    color: #667eea;
}

.nav-button.active:hover {
    background: #5568d3;
    color: white;
}

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #666;
    font-weight: 500;
}

/* Вкладки приложения */
.app-tab {
    display: none;
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.app-tab.active {
    display: block;
    animation: fadeIn 0.3s;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.tab-header h2 {
    color: #667eea;
    font-size: 28px;
}

/* Карточки Workspaces */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.workspace-card {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
}

.workspace-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.workspace-card h3 {
    color: #333;
    margin-bottom: 10px;
}

.card-footer {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* Процесс обработки */
.process-container {
    max-width: 800px;
    margin: 0 auto;
}

.step-card {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.step-card h3 {
    color: #667eea;
    margin-bottom: 15px;
}

/* Зона загрузки файлов */
.upload-zone {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    background: white;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: #667eea;
    background: #f9f9ff;
}

.upload-zone.dragover {
    border-color: #667eea;
    background: #f0f0ff;
    transform: scale(1.02);
}

.upload-content p {
    margin: 10px 0;
}

/* Preview файлов */
.files-preview {
    margin-top: 20px;
}

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

.files-header h4 {
    color: #667eea;
}

.files-grid {
    display: grid;
    gap: 10px;
}

.file-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-remove {
    background: #ef4444;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* История Jobs */
.jobs-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.job-card {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e0e0e0;
}

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

.job-header h4 {
    color: #333;
    font-size: 18px;
}

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-secondary {
    background: #e5e7eb;
    color: #374151;
}

.job-body p {
    margin: 8px 0;
    color: #666;
}

/* Progress bar малый */
.progress-bar-sm {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill-sm {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
}

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-header h3 {
    color: #667eea;
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: #333;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

/* Progress bar (модальное окно) */
.progress-container {
    padding: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

#progress-text {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

#progress-details {
    text-align: center;
    color: #666;
    margin-top: 10px;
}

/* Вспомогательные классы */
.text-muted {
    color: #888;
    font-size: 14px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 18px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 18px;
}

.error {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

/* Футер */
footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 40px;
}

/* Адаптивность */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .auth-container {
        padding: 30px 20px;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .app-nav {
        flex-wrap: wrap;
    }

    .nav-user {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

/* Переключение экранов app-content */
.app-content {
    display: none;
}

.app-content.active {
    display: block;
}


/* Кнопка удаления workspace */
.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    width: 24px;
    height: 24px;
    font-size: 20px;
    font-weight: 300;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    line-height: 1;
}

.delete-btn:hover {
    color: #666;
    transform: scale(1.2);
}

.delete-btn:active {
    transform: scale(0.95);
}

.workspace-card {
    position: relative;
    padding-right: 50px; /* Место для кнопки удаления */
}

/* Checkbox fix */
.form-group input[type="checkbox"] {
    width: auto !important;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.form-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Staff Table Styles */
.staff-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.staff-table th,
.staff-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.staff-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.staff-table tr:hover {
    background: #f5f5f5;
}

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

.staff-list {
    padding: 20px 0;
}

/* Custom Dropdown for Templates */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.custom-select-trigger {
    padding: 10px 15px;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-select-trigger::after {
    content: '▼';
    font-size: 10px;
    margin-left: 10px;
}

.custom-select.open .custom-select-trigger::after {
    content: '▲';
}

.custom-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.custom-select.open .custom-options {
    display: block;
}

.custom-option {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-option:hover {
    background: var(--bg-tertiary);
}

.custom-option.selected {
    background: var(--primary-color);
    color: white;
}

.custom-option .delete-template-btn {
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 8px;
    border-radius: 4px;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.custom-option .delete-template-btn:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.2);
}

.custom-option.create-new {
    color: var(--primary-color);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

#modal-progress.show { z-index: 9999 !important; }
#modal-progress.show { z-index: 9999 !important; }
