/* =====================================================
   AgavaCloud Public Website Styles
   ===================================================== */

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

:root {
    /* Brand Colors */
    --color-primary: #5c31ff;
    --color-primary-dark: #4a27cc;
    --color-primary-light: #7b5cff;

    /* Neutral Colors */
    --color-bg: #f5f7fa;
    --color-white: #ffffff;
    --color-text: #1a1a2e;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;

    /* Accent Colors */
    --color-accent-orange: #f59e0b;
    --color-accent-green: #10b981;
    --color-accent-blue: #3b82f6;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #5c31ff 0%, #3b82f6 50%, #06b6d4 100%);
    --gradient-dark: linear-gradient(-55deg, #d65827, #346691, #0088cc, #6c2c99);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 50px -12px rgba(0, 0, 0, 0.15);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --container-max: 1200px;
    --header-height: 70px;
    --nav-height: 50px;
}

html {
    scroll-behavior: smooth;
}

body.public-body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Header === */
.public-header {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--color-text);
    transition: opacity 0.2s ease;
}

.header-logo:hover {
    opacity: 0.85;
}

.header-logo svg {
    color: var(--color-primary);
    height: 42px;
    width: auto;
}

.logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-accent {
    font-weight: 300;
    color: var(--color-primary);
}

/* === Navigation === */
.public-nav {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    height: var(--nav-height);
    position: sticky;
    top: var(--header-height);
    z-index: 99;
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 20px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--color-primary-light);
    border-radius: 2px;
}

.nav-link-cabinet {
    margin-left: auto;
    background: transparent;
    color: rgba(255, 255, 255, 0.85) !important;
    border: none;
    font-weight: 500;
}

.nav-link-cabinet:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff !important;
}

/* === Content === */
.public-content {
    flex: 1;
    padding: 40px 0;
}

.content-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

/* === Footer === */
.public-footer {
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    margin-top: auto;
}

.footer-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 24px;
}

.footer-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

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

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

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

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

/* === Common Components === */
.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    margin-bottom: 32px;
    max-width: 600px;
}

.card {
    background: var(--color-white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

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

/* === Landing Page === */
.landing-hero {
    text-align: center;
    padding: 60px 0 40px;
}

.landing-hero .page-title {
    font-size: 3rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-hero .page-subtitle {
    margin: 0 auto 40px;
    font-size: 1.25rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.feature-card {
    background: var(--color-white);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    border: 1px solid var(--color-border);
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--color-primary-light);
}

.feature-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--gradient-primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.feature-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text);
}

.feature-desc {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* === Pricing Page === */
.pricing-table-wrapper {
    overflow-x: auto;
    margin-top: 32px;
}

.pricing-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

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

.pricing-table th {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
}

.pricing-table tr:hover {
    background: rgba(92, 49, 255, 0.03);
}

.pricing-table .price-cell {
    font-weight: 700;
    color: var(--color-primary);
    font-size: 1.1rem;
}

.pricing-table .check-icon {
    color: var(--color-accent-green);
    font-size: 1.2rem;
}

.pricing-table .cross-icon {
    color: var(--color-text-secondary);
    opacity: 0.5;
}

/* === News Page === */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
    margin-top: 32px;
}

.news-card {
    background: var(--color-white);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: all 0.3s ease;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.news-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: var(--gradient-primary);
}

.news-card-body {
    padding: 24px;
}

.news-card-date {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text);
    line-height: 1.4;
}

.news-card-excerpt {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

/* === Login Page === */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.login-card {
    background: var(--color-white);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
}

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

.login-header svg {
    color: var(--color-primary);
    height: 48px;
    margin-bottom: 16px;
}

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

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-white);
    color: var(--color-text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(92, 49, 255, 0.1);
}

.form-actions {
    margin-top: 28px;
}

.form-actions .btn {
    width: 100%;
    padding: 14px;
}

.form-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.form-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

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

.form-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
}

.form-success {
    background: #ecfdf5;
    color: #059669;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 20px;
    border: 1px solid #a7f3d0;
}

/* === Document Page with Sidebar === */
.doc-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.doc-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--color-white);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--color-border);
    position: sticky;
    top: calc(var(--header-height) + var(--nav-height) + 20px);
    max-height: calc(100vh - var(--header-height) - var(--nav-height) - 80px);
    overflow-y: auto;
}

.doc-sidebar-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.doc-sidebar-link {
    display: block;
    padding: 10px 12px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.doc-sidebar-link:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.doc-sidebar-link.active {
    background: rgba(92, 49, 255, 0.1);
    color: var(--color-primary);
    font-weight: 500;
}

.doc-main {
    flex: 1;
    min-width: 0;
}

/* === Responsive === */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --nav-height: auto;
    }

    .header-container {
        padding: 0 16px;
    }

    .logo-text {
        font-size: 1.5rem;
    }

    .nav-container {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-link {
        padding: 8px 14px;
        font-size: 0.875rem;
    }

    .nav-link-cabinet {
        margin-left: 0;
        order: -1;
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
    }

    .content-container {
        padding: 0 16px;
    }

    .landing-hero .page-title {
        font-size: 2rem;
    }

    .page-title {
        font-size: 1.75rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }

    .doc-layout {
        flex-direction: column;
    }

    .doc-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }

    .login-card {
        padding: 32px 24px;
    }

    .footer-info {
        flex-direction: column;
        text-align: center;
    }
}

/* === Modal & Dropdown Styles === */

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(4px);
}

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

.modal-content {
    background: var(--color-white);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* User Menu Dropdown */
.user-menu-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--color-primary);
    border: none;
    cursor: pointer;
    color: #fff;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    height: 100%;
}

.user-menu-btn:hover,
.user-menu-btn.active {
    background: var(--color-primary-dark);
}

.user-menu-icon {
    opacity: 0.8;
}

.user-menu-btn.active .user-menu-icon {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--color-white);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.dropdown-item:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

/* === Login Dropdown === */
.login-dropdown-container {
    position: relative;
    margin-left: auto;
}

.login-dropdown-menu {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: 360px;
    background: var(--color-white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.login-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.login-dropdown-header {
    text-align: center;
    margin-bottom: 20px;
}

.login-dropdown-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.auth-tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
}

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

.auth-tab-btn.active {
    border-bottom-color: var(--color-primary);
    color: var(--color-primary);
    font-weight: 600;
}

.login-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 0;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    margin-bottom: 16px;
    transition: color 0.2s ease;
}

.login-back-btn:hover {
    color: var(--color-text);
}

/* Animations for form switching */
.form-fade-enter {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Стабилизация dropdown-меню на мобильных */
@media (max-width: 768px) {
    /* Меню пользователя: показываем под кнопкой имени, а не снизу экрана */
    .user-dropdown-menu {
        position: absolute;
        right: 0;
        left: auto;
        top: calc(100% + 8px);
        bottom: auto;
        width: min(92vw, 280px);
        max-height: min(70dvh, 420px);
        overflow-y: auto;
        transform: translateY(-10px);
    }

    .user-dropdown-menu.active {
        transform: translateY(0);
    }

    /* Гостевой dropdown логина оставляем как мобильную панель снизу */
    .login-dropdown-menu {
        position: fixed;
        left: 50%;
        right: auto;
        top: auto;
        bottom: 12px;
        width: min(92vw, 360px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        transform: translate(-50%, 10px);
    }

    .login-dropdown-menu.active {
        transform: translate(-50%, 0);
    }
}

@media (max-width: 480px) {
    .user-dropdown-menu {
        width: min(94vw, 280px);
        border-radius: 10px;
        right: 0;
    }

    .login-dropdown-menu {
        width: min(94vw, 360px);
        border-radius: 10px;
        bottom: 8px;
        padding: 16px;
    }
}
