/*
  ================================================================================
  Vertex Admin Panel - Main Stylesheet
  Version: 2.2 (Aesthetic & Layout Fixes)
  ================================================================================
*/

/* --- Import & Global Reset --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
/* --- Components --- */
@import url('components.css');

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* THEME VARIABLES */
:root {
    /* -- Structure & Text -- */
    --bg-color: #0a0a0a;
    --glass-bg: rgba(26, 26, 26, 0.6);
    --text-color: #f5f5f5;
    --primary-accent: #ffffff;
    --secondary-text: #a3a3a3;
    --input-bg: #1a1a1a;
    --border-color: rgba(255, 255, 255, 0.15);
    --disabled-bg: #3f3f46;
    --disabled-text: #71717a;
    /* -- Semantic Colors -- */
    --error-color: #f43f5e;
    --success-color: #4ade80;
    --info-color: #3b82f6;
    /* -- Badge Colors -- */
    --offline-color: #3b82f6;
    --roleplay-color: #8b5cf6;
    /* -- Animation Particle Color -- */
    --particle-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="light"] {
    /* -- Structure & Text -- */
    --bg-color: #f4f4f5;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --text-color: #1f2937;
    --primary-accent: #111827;
    --secondary-text: #6b7280;
    --input-bg: #ffffff;
    --border-color: rgba(0, 0, 0, 0.1);
    --disabled-bg: #e5e7eb;
    --disabled-text: #9ca3af;
    /* -- Animation Particle Color -- */
    --particle-color: rgba(0, 0, 0, 0.05);
}

/* --- Core Body & Typography --- */
html {
    font-size: 12.8px;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    color: var(--text-color);
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 1rem 0;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
}

h1 {
    font-size: 2rem;
}

/* Center aligned headings for login and panel */
#login-container h1,
#login-container h2,
.panel-header h2 {
    text-align: center;
}

h2 {
    font-size: 1.5rem;
    color: var(--secondary-text);
    font-weight: 400;
}

h3 {
    text-align: left;
    margin-bottom: 1.5rem;
    color: var(--secondary-text);
    font-weight: 400;
}

h4 {
    margin-top: 0;
    font-weight: 600;
    color: var(--primary-accent);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* Background Animation*/
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    margin: 0;
    padding: 0;
}

.bg-animation li {
    position: absolute;
    display: block;
    list-style: none;
    width: 20px;
    height: 20px;
    background: var(--particle-color);
    animation: animateParticles 20s linear infinite;
    bottom: -200px;
    border-radius: 20%;
}

@keyframes animateParticles {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
        border-radius: 20%;
    }

    100% {
        transform: translateY(-120vh) rotate(720deg);
        opacity: 0;
        border-radius: 50%;
    }
}

.bg-animation li:nth-child(1) {
    left: 10%;
    width: 80px;
    height: 80px;
    animation-delay: 0s;
}

.bg-animation li:nth-child(2) {
    left: 20%;
    width: 30px;
    height: 30px;
    animation-delay: 1.5s;
    animation-duration: 10s;
}

.bg-animation li:nth-child(3) {
    left: 25%;
    width: 10px;
    height: 10px;
    animation-delay: 5.5s;
}

.bg-animation li:nth-child(4) {
    left: 40%;
    width: 60px;
    height: 60px;
    animation-delay: 0s;
    animation-duration: 15s;
}

.bg-animation li:nth-child(5) {
    left: 70%;
    width: 20px;
    height: 20px;
    animation-delay: 3.5s;
}

.bg-animation li:nth-child(6) {
    left: 80%;
    width: 120px;
    height: 120px;
    animation-delay: 1s;
}

.bg-animation li:nth-child(7) {
    left: 32%;
    width: 160px;
    height: 160px;
    animation-delay: 7s;
}

.bg-animation li:nth-child(8) {
    left: 55%;
    width: 20px;
    height: 20px;
    animation-delay: 15s;
    animation-duration: 40s;
}

.bg-animation li:nth-child(9) {
    left: 15%;
    width: 15px;
    height: 15px;
    animation-delay: 2s;
    animation-duration: 30s;
}

.bg-animation li:nth-child(10) {
    left: 90%;
    width: 160px;
    height: 160px;
    animation-delay: 4s;
    animation-duration: 9s;
}

/* --- Core Layout & Structure (No changes, already correct) --- */
.container {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: fadeIn 0.5s ease-in-out;
    z-index: 1;
}

#admin-panel {
    max-width: 87.5rem; 
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

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

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

.dashboard-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    transition: flex-direction 0.3s ease-in-out;
}

.left-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1;
    transition: flex-basis 0.3s ease-in-out;
    min-width: 0;
}

.dashboard-column {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
}

html[data-theme="light"] .dashboard-column {
    background: #ffffff;
    border: 1px solid var(--border-color);
}

/* --- General Form Elements --- */

input,
textarea,
select {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
    margin-bottom: 1.5rem; 
}

textarea {
    resize: vertical;
    min-height: 80px; 
}

label {
    display: block;
    font-weight: 600;
    color: var(--primary-accent); 
    margin: 0;
}

.form-hint {
    display: block;
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin: 0.25rem 0 0 0; 
}

label + .form-hint {
    margin-top: 0.25rem;
}

.form-hint + input,
.form-hint + textarea,
label + input,
label + textarea {
    margin-top: 0.5rem;
}

h4 + *,
.capability-header > * {
    margin-top: 0;
}

input + label,
textarea + label,
.checkbox-grid + label,
.token-grid + label,
div[style*="display: flex"] + label {
    margin-top: 1.5rem;
}

.switch-container + label {
    margin-top: 1.5rem;
}

/* --- General Button Styles (No changes, already correct) --- */
button {
    padding: 14px;
    border: 1px solid var(--primary-accent);
    border-radius: 8px;
    background-color: var(--primary-accent);
    color: var(--bg-color);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background-color: transparent;
    color: var(--primary-accent);
}

button:focus-visible {
    outline: 2px solid var(--primary-accent);
    outline-offset: 2px;
}

button:disabled {
    background-color: var(--disabled-bg);
    border-color: var(--disabled-bg);
    color: var(--disabled-text);
    cursor: not-allowed;
}

form button[type="submit"],
form button[type="button"]:not([class*="-btn"]),
#login-btn {
    width: 100%;
}

.secondary-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--secondary-text);
    color: var(--secondary-text);
}

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

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* --- App-Specific UI (Header, Loader, Toasts) --- */
.main-header-wrapper {
    position: relative;
    margin-bottom: 2rem;
}

.header-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#logout-btn,
#theme-toggle-btn {
    height: 40px;
    border-radius: 12px;
    background-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#logout-btn {
    padding: 0 16px;
    border: 1px solid var(--secondary-text);
    color: var(--secondary-text);
}

#logout-btn:hover {
    background-color: var(--primary-accent);
    color: var(--bg-color);
    border-color: var(--primary-accent);
}

#theme-toggle-btn {
    width: 40px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--text-color);
    color: var(--text-color);
}

#theme-toggle-btn:hover {
    border-color: var(--primary-accent);
    color: var(--primary-accent);
    background-color: rgba(128, 128, 128, 0.1);
}

#theme-toggle-btn svg {
    position: absolute;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.sun-icon {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
}

.moon-icon {
    transform: translateY(100%) rotate(-90deg);
    opacity: 0;
}

html[data-theme="light"] .sun-icon {
    transform: translateY(-100%) rotate(90deg);
    opacity: 0;
}

html[data-theme="light"] .moon-icon {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
}

#app-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease-out;
}

#app-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Use CSS variable for loader text color */
#app-loader p {
    color: var(--text-color);
    margin-top: 25px;
    font-size: 1.2rem;
    animation: text-pulse 2s infinite alternate ease-in-out;
}

.loader-logo {
    animation: logo-pulse 2s infinite alternate ease-in-out;
}

.loader-logo .logo-bg {
    fill: rgba(255, 255, 255, 0.05);
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1;
}

.loader-logo .logo-line {
    fill: none;
    stroke: var(--primary-accent);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 235;
    stroke-dashoffset: 235;
    animation: draw-line 2.5s ease-in-out forwards;
}

@keyframes draw-line {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes logo-pulse {
    from {
        transform: scale(0.98);
        opacity: 0.8;
    }

    to {
        transform: scale(1.02);
        opacity: 1;
    }
}

@keyframes text-pulse {
    from {
        opacity: 0.6;
    }

    to {
        opacity: 1;
    }
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Toast styles */
.toast {
    background-color: var(--input-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 10px;
    border-left: 5px solid var(--primary-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

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

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

.toast.info {
    border-left-color: var(--info-color);
}

/*
================================================================================
  Content Loader Styles
  - Used for dynamically loaded content sections like the model explorer.
================================================================================
*/

.content-loader-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px; /* Ensures the loader is visible even in a small container */
    padding: 2rem;
    color: var(--secondary-text);
    text-align: center;
}

.content-loader-wrapper .loader-logo {
    width: 60px; /* A smaller version for inline content */
    height: auto;
    margin-bottom: 1rem;
    animation: logo-pulse 2s infinite alternate ease-in-out; /* Re-use existing animation */
}

.content-loader-wrapper .loader-logo .logo-bg {
    fill: rgba(128, 128, 128, 0.05);
    stroke: rgba(128, 128, 128, 0.1);
    stroke-width: 1;
}

.content-loader-wrapper .loader-logo .logo-line {
    fill: none;
    stroke: var(--secondary-text); /* Use a less prominent color */
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 235;
    stroke-dashoffset: 235;
    animation: draw-line 2.5s ease-in-out forwards; /* Re-use existing animation */
}

.content-loader-wrapper p {
    font-size: 1rem;
    font-weight: 500;
    animation: text-pulse 2s infinite alternate ease-in-out; /* Re-use existing animation */
}

/*
================================================================================
  RESPONSIVE DESIGN - MEDIA QUERIES
================================================================================
*/

/* --- Tablets (1024px) --- */
@media (max-width: 1024px) {
    body {
        padding: 0;
    }


    #admin-panel {
        max-width: 1400px;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        position: relative;
        transition: max-width 0.3s ease-in-out, padding 0.3s ease-in-out, border-radius 0.3s ease-in-out;
    }

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

    .main-header-wrapper {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.25rem;
        position: static;
        margin-bottom: 2.5rem;
    }

    .panel-header h2 {
        margin: 0;
    }

    .header-actions {
        position: static;
        transform: none;
        width: 100%;
        justify-content: center;
    }
}


/* --- Mobile Devices (640px) --- */
@media (max-width: 640px) {
    #admin-panel {
        padding: 1.5rem 1rem;
    }

    .dashboard-column {
        padding: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    input,
    textarea,
    select {
        padding: 12px;
        margin-bottom: 1rem;
    }

    button {
        padding: 12px;
        font-size: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* --- Ultra Narrow Screens --- */
@media (max-width: 420px) {
    #admin-panel {
        padding: 1rem 0.5rem
    }

    .dashboard-column {
        padding: 0.8rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    h4 {
        font-size: 1rem;
    }

    #offline-fields div[style*="display: flex"] {
        flex-direction: column;
    }

    #notification-form div[style*="display: flex"] {
        flex-direction: column;
    }

    button {
        padding: 10px;
        font-size: 0.9rem;
    }

    #logout-btn {
        height: 36px;
        padding: 0 12px;
    }

    #theme-toggle-btn {
        width: 36px;
        height: 36px;
    }

    #toast-container {
        right: 10px;
        bottom: 10px;
        width: calc(100% - 20px);
        align-items: center;
    }

    .toast {
        width: 100%;
        max-width: 380px;
    }
}
