/* =============================================================================
   Text Write - Основные стили
   ============================================================================= */

:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-bg: #f8fafc;
    --color-bg-card: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* =============================================================================
   Header
   ============================================================================= */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.logo:hover {
    text-decoration: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-link {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.user-name {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* =============================================================================
   Flash Messages
   ============================================================================= */

.flash-messages {
    position: fixed;
    top: 60px;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--color-bg-card);
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.flash-error { border-left: 4px solid var(--color-danger); }
.flash-success { border-left: 4px solid var(--color-success); }
.flash-warning { border-left: 4px solid var(--color-warning); }
.flash-info { border-left: 4px solid var(--color-primary); }

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    margin-left: 1rem;
}

/* =============================================================================
   Main Content
   ============================================================================= */

.main {
    padding: 2rem;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

.container-sm {
    max-width: 600px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

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

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
}

/* =============================================================================
   Forms
   ============================================================================= */

.form-card {
    background: var(--color-bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-card);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* =============================================================================
   Auth Pages
   ============================================================================= */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-box {
    background: var(--color-bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-box h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
}

.auth-form {
    text-align: left;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-footer {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.auth-note {
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
}

/* =============================================================================
   Projects List
   ============================================================================= */

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.project-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.project-title a {
    color: var(--color-text);
}

.project-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.project-discipline {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.project-date {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
}

.project-actions {
    display: flex;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-text-secondary);
}

.badge-admin {
    background: var(--color-primary);
    color: white;
}

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

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

/* =============================================================================
   Empty State
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-secondary);
}

.empty-state p {
    margin-bottom: 1rem;
}

/* =============================================================================
   Tables
   ============================================================================= */

.table-container {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table th {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    background: var(--color-bg);
}

.table tr.inactive {
    background: #fef3c7;
}

.table .actions {
    white-space: nowrap;
}

/* =============================================================================
   Utilities
   ============================================================================= */

.inline {
    display: inline;
}

/* =============================================================================
   Responsive
   ============================================================================= */

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

    .project-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .project-actions {
        width: 100%;
    }

    .project-actions .btn {
        flex: 1;
    }

    .table-container {
        overflow-x: auto;
    }
}

/* =============================================================================
   Settings Pages
   ============================================================================= */

.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section {
    background: var(--color-bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.settings-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-description {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.settings-form {
    max-width: 500px;
}

/* Rules List */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rules-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.rules-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rules-item-name {
    font-weight: 500;
}

/* Rules Cards (alternative view) */
.rules-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.rules-card {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.rules-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.rules-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.rules-card-body {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

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

/* Rules Edit Form */
.breadcrumb {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--color-text-secondary);
}

.rules-form {
    background: var(--color-bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.rules-textarea {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    min-height: 400px;
    resize: vertical;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
}

.system-rules-hint {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.system-rules-hint h3 {
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.system-rules-hint p {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-bottom: 0.75rem;
}

.system-rules-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--color-bg-card);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.badge-secondary {
    background: var(--color-bg);
    color: var(--color-text-secondary);
}

/* =============================================================================
   Prompts Settings Page
   ============================================================================= */

.prompts-section {
    background: var(--color-bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompt-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    gap: 1rem;
}

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

.prompt-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.prompt-preview {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

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

.prompt-form textarea {
    min-height: 120px;
}
