/**
 * Bastion Digital - Main Stylesheet
 * NEO UI Kit Standards
 * 
 * @version 1.0
 * @author Kimi Code
 */

/* ========================================
   1. CSS VARIABLES (NEO Design System)
   ======================================== */
:root {
    /* Colors - Warm Theme (Bastion Stone) */
    --accent: #937A49;
    --accent-light: #B89B6A;
    --accent-dark: #6B5632;
    
    /* Backgrounds */
    --bg-primary: #F5F3EF;
    --bg-secondary: #EDE9E3;
    --bg-tertiary: #E5E0D8;
    --bg-card: #FFFFFF;
    
    /* Text */
    --text-primary: #2C2416;
    --text-secondary: #5C4F3A;
    --text-muted: #8B7D65;
    
    /* Borders */
    --border: #D4CDC0;
    --border-light: #E8E3DA;
    
    /* Status */
    --success: #4A7C59;
    --warning: #C9A227;
    --error: #A94442;
    --info: #4A7298;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(44, 36, 22, 0.05);
    --shadow-md: 0 4px 12px rgba(44, 36, 22, 0.08);
    --shadow-lg: 0 8px 24px rgba(44, 36, 22, 0.12);
    
    /* Typography */
    --font-sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Spacing */
    --padding-sm: 10px 12px;
    --padding-md: 16px 20px;
    --padding-lg: 20px 24px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-round: 50%;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ========================================
   2. BASE STYLES
   ======================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

/* Отключаем bold для всех элементов */
b, strong, h1, h2, h3, h4, h5, h6 {
    font-weight: 400;
}

/* Табличные цифры для финансов */
.stat-value, .price, .total {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* ========================================
   3. AUTHENTICATION PAGES
   ======================================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--padding-lg);
    margin-bottom: 24px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.auth-logo .logo-icon {
    width: 40px;
    height: 40px;
    color: white;
}

.auth-title {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-muted);
}

/* ========================================
   4. FORMS
   ======================================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.2;
    min-height: 20px;
}

.form-group label .input-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    height: 40px;
    box-sizing: border-box;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(147, 122, 73, 0.1);
}

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

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-control {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
}

.password-toggle:hover {
    color: var(--accent);
}

.password-toggle .toggle-icon {
    width: 18px;
    height: 18px;
}

.form-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-hint .hint-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.form-error {
    display: none;
    padding: 10px 12px;
    background: rgba(169, 68, 66, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 14px;
}

.form-error.visible {
    display: block;
}

/* ========================================
   5. BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: var(--padding-sm);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-sans);
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Spinner для кнопки */
.btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   6. FOOTER
   ======================================== */
.auth-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-footer p {
    margin-bottom: 4px;
}

.auth-footer .copyright {
    font-size: 12px;
    opacity: 0.8;
}

/* ========================================
   7. RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .auth-container {
        padding: 16px;
        justify-content: flex-start;
        padding-top: 60px;
    }
    
    .auth-card {
        padding: 24px 20px;
    }
    
    .auth-logo {
        width: 64px;
        height: 64px;
    }
    
    .auth-logo .logo-icon {
        width: 32px;
        height: 32px;
    }
    
    .auth-title {
        font-size: 24px;
    }
}

/* ========================================
   8. UTILITY CLASSES
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}
/* ========================================
   9. MODAL STYLES
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1001;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: var(--padding-md);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: var(--padding-md);
    border-top: 1px solid var(--border-light);
}

/* Toast container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    color: #fff;
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    animation: toastSlideIn 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }

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

/* ========================================
   10. DRAWER STYLES
   ======================================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 520px;
    max-width: 100%;
    height: 100vh;
    background: var(--bg-card);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.drawer.active {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.drawer-title {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.drawer-title i {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.drawer-close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.drawer-close:hover {
    background: var(--bg-tertiary);
    color: var(--error);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.drawer-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}

.drawer-footer .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .drawer {
        width: 100%;
    }
}
