/* ==============================================================================
   AMETIST IOT PLATFORM — style.css
   Core Reset, Design Tokens, Global Styles, Navigation Header & Dropdown Menu
   ============================================================================== */

/* --- CSS Variables / Design Tokens --- */
:root {
    --bg-deep: #050514;
    --bg-dark-1: #080520;
    --bg-dark-2: #0e0a2d;
    --bg-card: rgba(18, 14, 42, 0.78);
    --bg-card-hover: rgba(28, 22, 62, 0.88);
    --bg-glass: rgba(255, 255, 255, 0.04);
    
    --border-subtle: rgba(124, 58, 237, 0.22);
    --border-glow: rgba(168, 85, 247, 0.5);
    --border-glass: rgba(255, 255, 255, 0.12);
    
    --purple-primary: #7c3aed;
    --purple-hover: #9333ea;
    --purple-accent: #a855f7;
    --purple-light: #c084fc;
    --purple-glow: rgba(124, 58, 237, 0.45);
    
    --neon-cyan: #38bdf8;
    --neon-cyan-glow: rgba(56, 189, 248, 0.4);
    --neon-emerald: #34d399;
    --neon-emerald-glow: rgba(52, 211, 153, 0.45);
    --neon-coral: #ef4444;
    --neon-amber: #f59e0b;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: radial-gradient(circle at 50% -15%, #180e3d 0%, #070519 50%, #03020a 100%) fixed;
    background-color: var(--bg-deep);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
    display: block;
}

ol, ul {
    list-style: none;
}

a {
    color: var(--neon-cyan);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--purple-light);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    background: none;
    border: none;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
    width: 100%;
}

/* --- Utility Containers --- */
.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* --- Scrollbar Customization --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(5, 5, 20, 0.8);
}
::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.4);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.7);
}

/* ==============================================================================
   HEADER & TOP NAVIGATION (menu_navsl)
   ============================================================================== */
.header-main {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(5, 5, 20, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(124, 58, 237, 0.15);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    transition: var(--transition-base);
}

.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 80px;
}

/* --- Logo Styled Identically to ametist-tech.ru --- */
.nav-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: var(--transition-base);
}

.nav-logo:hover {
    transform: translateY(-1px);
}

.brand-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.7));
    transition: transform 0.3s ease;
}

.nav-logo:hover .brand-logo-img {
    transform: scale(1.1);
}

.brand-title-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
}

.brand-name {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.95);
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.brand-slogan {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: #a78bfa;
    text-transform: uppercase;
    margin-top: 2px;
}

.nav-logo:hover .brand-name {
    color: #ffffff;
}

.brand-accent {
    color: #ffffff;
    margin-left: 4px;
}

.nav-indev-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.35);
    color: #a78bfa;
    margin-left: 8px;
}

.nav-indev-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 6px #34d399;
    animation: pulseDot 2s infinite ease-in-out;
}

/* --- Nav Text Links --- */
.nav-text-link {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 6px 12px;
    transition: color 0.2s ease;
}

.nav-text-link:hover {
    color: #ffffff;
}

.nav-auth-links {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 14px;
}

@media (max-width: 768px) {
    .nav-auth-links {
        display: none;
    }
}

/* --- Unauthenticated Menu (Вход / Регистрация) --- */
.unauth-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: #ffffff;
    cursor: pointer;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.mobile-nav-toggle:hover {
    background: rgba(124, 58, 237, 0.2);
    border-color: var(--purple-accent);
}

.auth-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all var(--transition-base);
}

.auth-link.login {
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    border-radius: 4px;
    border: 1px solid rgba(124, 58, 237, 0.35);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
}

.auth-link.login:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(168, 85, 247, 0.5);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.25);
}

.auth-link.register {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: 4px;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.4);
}

.auth-link.register:hover {
    transform: scale(1.05);
    box-shadow: 0 0 28px rgba(168, 85, 247, 0.65);
    color: #ffffff;
}

/* --- Authenticated User Menu & Dropdown --- */
.user-menu-wrapper {
    position: relative;
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 8px 20px;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-base);
    backdrop-filter: blur(12px);
}

.menu-toggle:hover {
    background: rgba(124, 58, 237, 0.15);
    border-color: var(--purple-accent);
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
    transform: translateY(-1px);
}

.menu-toggle.active {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--purple-light);
    box-shadow: 0 0 25px rgba(124, 58, 237, 0.45);
}

.hamburger-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 20px;
}

.hamburger-line {
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: all var(--transition-base);
}

.menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

.menu-text {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* --- Dropdown Menu Container --- */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 300px;
    background: rgba(13, 9, 34, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glow);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(124, 58, 237, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.97);
    transition: all var(--transition-base);
    z-index: 1010;
    overflow: hidden;
}

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

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 24px;
    width: 14px;
    height: 14px;
    background: rgba(13, 9, 34, 0.95);
    transform: rotate(45deg);
    border-left: 1px solid var(--border-glow);
    border-top: 1px solid var(--border-glow);
}

/* User Info Header in Dropdown */
.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: rgba(124, 58, 237, 0.08);
    border-bottom: 1px solid var(--border-subtle);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    border: 2px solid rgba(192, 132, 252, 0.5);
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.15rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.user-status {
    color: var(--neon-emerald);
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--neon-emerald);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--neon-emerald);
    animation: statusPulse 2s infinite ease-in-out;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.close-menu {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.close-menu:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--neon-coral);
    color: #ffffff;
}

/* Menu Items List */
.menu-list {
    padding: 10px 0;
}

.menu-item {
    transition: var(--transition-fast);
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.menu-link:hover {
    background: rgba(124, 58, 237, 0.12);
    color: #ffffff;
    padding-left: 24px;
}

.menu-link:hover::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--purple-accent);
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px var(--purple-accent);
}

.menu-icon {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 8px 16px;
}

.admin-link {
    color: var(--neon-amber);
}
.admin-link:hover {
    color: #fde047;
    background: rgba(245, 158, 11, 0.12);
}

.logout-link {
    color: var(--neon-coral);
}
.logout-link:hover {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
}

.menu-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
}

.menu-version {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--purple-light);
    letter-spacing: 0.05em;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

/* Background Overlay for mobile menu */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 1005;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

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

/* --- Alerts & Flash Messages --- */
.alert {
    padding: 16px 22px;
    border-radius: var(--radius-md);
    margin: 20px 0;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.alert-error, .error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.alert-success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #6ee7b7;
}

/* --- Buttons Helper Classes --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all var(--transition-base);
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 50%, #a855f7 100%);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
    border-color: rgba(168, 85, 247, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(168, 85, 247, 0.6);
    color: #ffffff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.btnform {
    display: inline-block;
    padding: 8px 18px;
    background: rgba(124, 58, 237, 0.15);
    font-size: 0.82rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--purple-light);
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.btnform:hover {
    background: var(--purple-primary);
    color: #ffffff;
    box-shadow: 0 0 15px var(--purple-glow);
}

.btndel {
    display: inline-block;
    padding: 8px 18px;
    background: rgba(239, 68, 68, 0.12);
    font-size: 0.82rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.btndel:hover {
    background: var(--neon-coral);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

/* --- Mobile & Tablet Responsiveness --- */
@media (max-width: 860px) {
    .auth-menu .nav-text-link {
        display: none !important;
    }
    .mobile-nav-toggle {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .nav-container {
        padding: 0 16px;
        height: 62px;
    }
    
    .nav-logo {
        gap: 10px;
    }
    
    .brand-logo-img {
        width: 32px;
        height: 32px;
    }
    
    .brand-name {
        font-size: 12px;
        letter-spacing: 0.14em;
    }
    
    .auth-menu {
        gap: 6px;
        margin: 0;
    }
    
    .auth-link.login {
        padding: 6px 12px;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.03em;
        white-space: nowrap;
    }
    
    .auth-link.register {
        padding: 6px 14px;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.05em;
        white-space: nowrap;
    }
    
    .dropdown-menu {
        position: fixed;
        top: 0;
        right: 0;
        width: 290px;
        height: 100vh;
        border-radius: 0;
        margin: 0;
        transform: translateX(100%);
        overflow-y: auto;
    }
    
    .dropdown-menu.active {
        transform: translateX(0);
    }
    
    .dropdown-menu::before {
        display: none;
    }
}

@media (max-width: 640px) {
    .brand-slogan {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .nav-container {
        padding: 0 12px;
        height: 56px;
    }
    
    .nav-logo {
        gap: 8px;
    }
    
    .brand-logo-img {
        width: 28px;
        height: 28px;
    }
    
    .brand-name {
        font-size: 11px;
        letter-spacing: 0.1em;
    }
    
    .auth-menu {
        gap: 5px;
    }
    
    .auth-link.login {
        padding: 5px 9px;
        font-size: 10.5px;
    }
    
    .auth-link.register {
        padding: 5px 10px;
        font-size: 10.5px;
        letter-spacing: 0.03em;
    }
    
    .mobile-nav-toggle {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 360px) {
    .nav-container {
        padding: 0 8px;
    }
    
    .brand-name {
        font-size: 10px;
        letter-spacing: 0.06em;
    }
    
    .auth-menu {
        gap: 4px;
    }
    
    .auth-link.login {
        padding: 4px 7px;
        font-size: 10px;
    }
    
    .auth-link.register {
        padding: 4px 8px;
        font-size: 10px;
        letter-spacing: 0.02em;
    }
    
    .mobile-nav-toggle {
        width: 28px;
        height: 28px;
    }
}
