@import 'variables.css';

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Roboto, system-ui, -apple-system, Segoe UI, Ubuntu, Cantarell, Noto Sans, sans-serif;
    font-size: 18px;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

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

a:hover {
    color: var(--color-primary-hover);
}

/* Layout */
html, body {
    height: 100%;
}
html {
    scrollbar-gutter: stable;
}

body {
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
    padding: var(--spacing-xl) 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Header & Footer */
.site-header {
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-md) 0;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.main-nav {
    display: flex;
    gap: var(--spacing-xl);
    align-items: center;
}

.nav-link {
    color: var(--color-text-muted);
    font-weight: 500;
}

.nav-link:hover {
    color: var(--color-primary);
}

.header-actions {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.site-footer {
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-xl) 0;
    text-align: center;
    color: var(--color-text-muted);
    margin-top: auto;
}

/* BEM Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 20px;
    cursor: pointer;
    border: 1px solid transparent;
    color: var(--color-text);
    transition: all 0.2s;
}

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

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

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

.btn--danger:hover {
    background-color: #dc2626; /* Slightly darker red */
    color: white;
}

.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

/* Forms */
.form__group {
    margin-bottom: var(--spacing-md);
}

.form__label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
}

.form__input {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* Fix Webkit Autofill Background */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--color-surface) inset !important;
    -webkit-text-fill-color: var(--color-text) !important;
    transition: background-color 5000s ease-in-out 0s;
}

input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px var(--color-surface) inset, 0 0 0 3px var(--color-focus-ring) !important;
    -webkit-text-fill-color: var(--color-text) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-error {
    color: var(--color-error);
    font-size: 0.875rem;
    margin-bottom: 15px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%);
    background: var(--color-bg);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--color-border);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

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

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

.modal-body {
    padding: 24px;
}

.modal-footer-links {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.modal-footer-links a {
    color: var(--color-primary);
    text-decoration: none;
}

.modal-footer-links a:hover {
    text-decoration: underline;
}

/* Button variants */
.btn--outline {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn--outline:hover {
    background-color: var(--color-surface);
    border-color: var(--color-primary);
}

/* Alerts */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border-left: 4px solid transparent;
}
.alert--info {
    background-color: rgba(99, 102, 241, 0.1);
    border-left-color: var(--color-primary);
    color: var(--color-primary);
}
.alert--success {
    background-color: rgba(34, 197, 94, 0.1);
    border-left-color: var(--color-success);
    color: var(--color-success);
}
.alert--warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-left-color: var(--color-warning);
    color: var(--color-warning);
}
.alert--error {
    background-color: rgba(239, 68, 68, 0.1);
    border-left-color: var(--color-error);
    color: var(--color-error);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 9999px;
}
.badge--default { background-color: var(--color-border); color: var(--color-text); }
.badge--primary { background-color: var(--color-primary); color: white; }
.badge--success { background-color: var(--color-success); color: white; }
.badge--warning { background-color: var(--color-warning); color: white; }
.badge--danger { background-color: var(--color-error); color: white; }

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--color-text);
    border-collapse: collapse;
}
.table th, .table td {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid var(--color-border);
    text-align: left;
}
.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
}
.table tbody tr:hover {
    background-color: rgba(0,0,0,0.02);
}

/* Dropdowns */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    min-width: 10rem;
    padding: 0.5rem 0;
    margin: 0.125rem 0 0;
    font-size: 1rem;
    color: var(--color-text);
    text-align: left;
    list-style: none;
    background-color: var(--color-surface);
    background-clip: padding-box;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.dropdown-menu.active {
    display: block;
}
.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.25rem 1.5rem;
    clear: both;
    font-weight: 400;
    color: var(--color-text);
    text-align: inherit;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
}
.dropdown-item:hover {
    color: var(--color-primary);
    background-color: rgba(99, 102, 241, 0.05);
}
.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
}

/* Tabs */
.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}
.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    color: var(--color-text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab-btn:hover {
    color: var(--color-text);
}
.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}

/* Tooltips */
.tooltip-trigger {
    position: relative;
    cursor: help;
}
.tooltip-trigger::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background-color: #333;
    color: #fff;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
}
.tooltip-trigger::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}
.tooltip-trigger:hover::before,
.tooltip-trigger:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-4px);
}
.tooltip-trigger:hover::after {
    transform: translateX(-50%);
}

/* Pagination */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
}
.page-item:first-child .page-link {
    border-top-left-radius: var(--radius-md);
    border-bottom-left-radius: var(--radius-md);
}
.page-item:last-child .page-link {
    border-top-right-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}
.page-item.active .page-link {
    z-index: 1;
    color: #fff;
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}
.page-item.disabled .page-link {
    color: var(--color-text-muted);
    pointer-events: none;
    cursor: auto;
    background-color: var(--color-bg);
    border-color: var(--color-border);
}
.page-link {
    position: relative;
    display: block;
    padding: 0.5rem 0.75rem;
    margin-left: -1px;
    line-height: 1.25;
    color: var(--color-primary);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
}
.page-link:hover {
    z-index: 2;
    color: var(--color-primary-hover);
    text-decoration: none;
    background-color: rgba(99, 102, 241, 0.05);
    border-color: var(--color-border);
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    min-width: 250px;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    color: #fff;
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.toast.active {
    opacity: 1;
    transform: translateY(0);
}
.toast--success { background-color: var(--color-success); }
.toast--error { background-color: var(--color-error); }
.toast--info { background-color: var(--color-primary); }

.mobile-auth {
    display: none;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #mobile-menu-toggle {
        display: block !important;
        grid-column: 3 / 4;
        grid-row: 1 / 2;
    }
    
    .header-inner {
        display: grid;
        grid-template-columns: 1fr auto auto;
        gap: 10px;
        align-items: center;
    }
    
    .logo {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        font-size: 1.25rem;
    }

    .header-actions {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        justify-content: flex-end;
    }

    .desktop-auth {
        display: none !important;
    }

    .mobile-auth {
        display: block;
        padding: 15px 20px 10px 20px;
        text-align: center;
        width: 100%;
    }
    
    .main-nav {
        display: none;
        flex-direction: column;
        grid-column: 1 / 4;
        grid-row: 2 / 3;
        width: 100%;
        background: var(--color-surface);
        padding: 5px 0;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        gap: 0;
        border: 1px solid var(--color-border);
        margin-top: 10px;
    }
    
    .main-nav.active {
        display: flex;
        animation: slideDown 0.3s ease-out forwards;
    }
    
    .nav-link {
        padding: 12px 20px;
        border-bottom: 1px solid var(--color-border);
        width: 100%;
        text-align: center;
    }
}

.profile-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

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

@media (max-width: 768px) {
    .profile-layout {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Предотвращение FOUC (мерцания модалок при загрузке) */
.modal-overlay, .modal { opacity: 0; visibility: hidden; }

/* Social Footer Styles */
.social-footer {
    display: flex;
    gap: 12px;
    align-items: center;
}
.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.15);
    color: var(--color-text-muted);
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-decoration: none;
}
.social-link:hover {
    color: #fff;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .social-link {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.social-link.facebook:hover { background: #1877F2; box-shadow: 0 5px 15px rgba(24, 119, 242, 0.4); }
.social-link.twitter:hover { background: #14171a; box-shadow: 0 5px 15px rgba(20, 23, 26, 0.4); }
html[data-theme="dark"] .social-link.twitter:hover { background: #fff; color: #000; box-shadow: 0 5px 15px rgba(255, 255, 255, 0.4); }
.social-link.instagram:hover { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); box-shadow: 0 5px 15px rgba(228, 64, 95, 0.4); }
.social-link.github:hover { background: #333; box-shadow: 0 5px 15px rgba(51, 51, 51, 0.4); }
html[data-theme="dark"] .social-link.github:hover { background: #fff; color: #000; box-shadow: 0 5px 15px rgba(255, 255, 255, 0.4); }
.social-link.youtube:hover { background: #FF0000; box-shadow: 0 5px 15px rgba(255, 0, 0, 0.4); }
.social-link.vk:hover { background: #0077FF; box-shadow: 0 5px 15px rgba(0, 119, 255, 0.4); }
