/* ====================================
   ГЛОБАЛЬНЫЕ СТИЛИ
   ==================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ====================================
   ЭКРАНЫ
   ==================================== */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* ====================================
   ЭКРАН АВТОРИЗАЦИИ
   ==================================== */

#login-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 24px;
    padding: 48px 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    color: var(--primary);
}

.login-container h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    margin-top: 16px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--danger);
    font-size: 14px;
}

/* ====================================
   КНОПКИ
   ==================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-sm {
    width: auto;
    padding: 8px 16px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: none;
    cursor: pointer;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ====================================
   SPINNER
   ==================================== */

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====================================
   ХЕДЕР
   ==================================== */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    font-size: 0;
}

.status-indicator.online {
    background: var(--success);
}

.status-indicator.offline {
    background: var(--text-secondary);
}

/* ====================================
   ТАБЫ
   ==================================== */

.tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 73px;
    z-index: 99;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 0 0 auto;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.02);
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

/* ====================================
   КОНТЕНТ
   ==================================== */

.tab-content {
    display: none;
    padding: 20px;
    padding-bottom: 100px;
}

.tab-content.active {
    display: block;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.content-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.btn-refresh {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-refresh:active {
    transform: rotate(180deg);
}

/* ====================================
   ЗАГРУЗКА
   ==================================== */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading p {
    margin-top: 16px;
    font-size: 15px;
}

/* ====================================
   СПИСОК ЭЛЕМЕНТОВ
   ==================================== */

.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    transition: all 0.3s ease;
}

.item-card:active {
    transform: scale(0.98);
}

.item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.item-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.status-badge.open {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.closed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.item-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.item-actions-row {
    display: flex;
    gap: 8px;
}

.btn-action {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action:hover {
    background: var(--bg);
}

.btn-action.success {
    border-color: var(--success);
    color: var(--success);
}

.btn-action.danger {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-action.active {
    background: var(--primary);
    color: white !important;
    font-weight: 700;
    border-width: 2px;
}

.btn-action.active svg {
    stroke: white !important;
}

.btn-action.success.active {
    background: var(--success);
    border-color: var(--success);
    color: white !important;
}

.btn-action.success.active svg {
    stroke: white !important;
}

.btn-action.danger.active {
    background: var(--danger);
    border-color: var(--danger);
    color: white !important;
}

.btn-action.danger.active svg {
    stroke: white !important;
}

.btn-action-full {
    width: 100%;
}

.btn-filter {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-filter:hover {
    background: var(--bg);
}

.btn-filter.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ====================================
   МОДАЛЬНОЕ ОКНО
   ==================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.3s ease;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.btn-close {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

/* ====================================
   TOAST УВЕДОМЛЕНИЯ
   ==================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ====================================
   INSTALL PROMPT
   ==================================== */

.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 20px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 999;
    animation: slideUp 0.3s ease;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.install-content svg {
    color: var(--primary);
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.install-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

.install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ====================================
   АНИМАЦИИ
   ==================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ====================================
   QUILL EDITOR СТИЛИ
   ==================================== */

.ql-toolbar {
    background: #f8fafc !important;
    border: none !important;
    border-bottom: 1px solid #e5e7eb !important;
    border-radius: 8px 8px 0 0 !important;
}

.ql-container {
    border: none !important;
    font-size: 15px !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

.ql-editor {
    min-height: 200px;
    padding: 16px !important;
}

.ql-editor.ql-blank::before {
    color: #94a3b8 !important;
    font-style: normal !important;
}

.ql-snow .ql-stroke {
    stroke: #64748b !important;
}

.ql-snow .ql-fill {
    fill: #64748b !important;
}

.ql-snow .ql-picker-label {
    color: #64748b !important;
}

.ql-toolbar button:hover,
.ql-toolbar button.ql-active {
    color: var(--primary) !important;
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--primary) !important;
}

.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill {
    fill: var(--primary) !important;
}

/* ====================================
   АДАПТИВНОСТЬ
   ==================================== */

@media (min-width: 768px) {
    .modal-content {
        max-width: 600px;
        margin: auto;
        border-radius: 24px;
        max-height: 80vh;
    }

    .modal.active {
        align-items: center;
    }

    .toast-container {
        top: auto;
        bottom: 20px;
    }
}
