/**
 * Passapp - Modern Minimal Design
 * Цветовая палитра: глубокий тёмно-синий + яркий акцент
 */

/* JetBrains Mono - локальные шрифты */
@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/JetBrainsMono-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.1);
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius: 12px;
    --radius-sm: 8px;
}

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

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

html, body {
    height: 100%;
}

body {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ==================== Layout ==================== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: 
        radial-gradient(ellipse at top, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.header-logo img {
    height: 32px;
    width: auto;
}

.header-logo span {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-nav a {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.header-nav a:hover {
    color: var(--text-primary);
    background: var(--accent-light);
}

.header-nav a.active {
    color: var(--accent);
}

/* ==================== Card ==================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    animation: fadeIn 0.4s ease;
}

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

.card-logo {
    text-align: center;
    margin-bottom: 32px;
}

.card-logo img {
    height: 48px;
    width: auto;
}

.card-title {
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.card-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
}

/* ==================== Form ==================== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s ease;
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==================== Links ==================== */

.links {
    text-align: center;
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 24px;
}

.links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.links a:hover {
    color: var(--accent);
}

/* ==================== Download App ==================== */

.download-app {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.download-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #3ddc84 0%, #2aa567 100%);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(61, 220, 132, 0.25);
}

.download-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(61, 220, 132, 0.35);
    filter: brightness(1.05);
}

.download-link:active {
    transform: translateY(0);
}

.download-link--full {
    width: 100%;
}

.download-label {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.download-version {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* ==================== Profile Layout ==================== */

.profile-layout {
    flex-direction: row !important;
    align-items: flex-start;
    gap: 24px;
    max-width: 900px;
    overflow-y: visible;
}

.content-card--auto {
    flex: none;
    width: 100%;
    max-width: 400px;
    overflow: visible;
}

.app-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.app-release-date {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 860px) {
    .profile-layout {
        flex-direction: column !important;
        overflow-y: visible;
    }
    
    .content-card--auto {
        max-width: none;
    }
}

/* ==================== Messages (legacy) ==================== */

.message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.message.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.message.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

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

/* ==================== Toast Notifications ==================== */

.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    font-size: 14px;
}

.toast.toast-hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

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

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

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

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

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast.error .toast-icon {
    color: var(--error);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

.toast.info .toast-icon {
    color: var(--accent);
}

@media (max-width: 640px) {
    .toast-container {
        top: 72px;
        right: 12px;
        left: 12px;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

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

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.content-card--editor {
    overflow: hidden;
}

.content-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-title::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--accent);
    border-radius: 2px;
}

/* ==================== Editor ==================== */

.editor-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.editor-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-wrapper .tox-tinymce {
    flex: 1 !important;
    height: auto !important;
}

/* TinyMCE overrides */
.tox-tinymce {
    border: none !important;
    border-radius: 0 !important;
}

.tox .tox-toolbar,
.tox .tox-toolbar__overflow,
.tox .tox-toolbar__primary {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border) !important;
}

.tox .tox-edit-area__iframe {
    background: var(--bg-input) !important;
}

.tox .tox-tbtn {
    color: var(--text-primary) !important;
}

.tox .tox-tbtn svg {
    fill: var(--text-primary) !important;
}

.tox .tox-tbtn:hover {
    background: var(--bg-input) !important;
    color: white !important;
}

.tox .tox-tbtn:hover svg {
    fill: white !important;
}

.tox .tox-tbtn--enabled,
.tox .tox-tbtn--enabled:hover {
    background: var(--accent) !important;
}

.tox .tox-tbtn--enabled svg {
    fill: white !important;
}

.tox .tox-toolbar__group:not(:last-of-type) {
    border-right: 1px solid var(--border) !important;
}

/* ==================== Status ==================== */

#status {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

#masterpassword {
    display: none;
    margin-bottom: 16px;
}

#decryptBtn,
#createBtn {
    display: none;
}

#editorSection {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

#editorSection.active {
    display: flex;
}

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

@media (max-width: 640px) {
    .card {
        padding: 24px;
    }
    
    .main-content {
        padding: 16px;
        overflow-y: auto;
    }
    
    .content-card {
        padding: 20px;
    }
    
    .header {
        padding: 0 16px;
    }
    
    .header-logo span {
        display: none;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
}

/* ==================== Modal ==================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 440px;
    animation: slideUp 0.3s ease;
}

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

.modal-danger {
    border-color: rgba(239, 68, 68, 0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Warning Box */
.warning-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    padding: 16px;
    color: #fca5a5;
}

.warning-box p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.warning-box p:last-child {
    margin-bottom: 0;
}

/* ==================== Danger Button ==================== */

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

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

.btn-danger-outline {
    background: transparent;
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.6);
}

.btn-sm {
    padding: 10px 16px;
    font-size: 13px;
}

/* Анимация загрузки для кнопок */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

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

/* ==================== Reset Section ==================== */

.reset-section {
    display: none;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.reset-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

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

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

