/* 
   ADMIN PORTAL - COSMIC SANGUINEM GRID SYSTEM
   Replacement for legacy admin styles.
*/

:root {
    /* Theme Colors */
    --admin-bg: #0a0000;
    --sidebar-bg: #0f0202;
    --card-bg: rgba(20, 5, 5, 0.85);
    --border-color: #330a0a;
    --blood-red: #8a0303;
    --blood-bright: #ff3232;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;

    /* Dimensions */
    --sidebar-width: 260px;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', sans-serif;
    background-color: var(--admin-bg);
    color: var(--text-main);
    overflow-x: hidden;
}

/* --- MAIN LAYOUT GRID --- */
.admin-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 100vh;
    height: 100vh;
    overflow: hidden;
}

/* --- SIDEBAR --- */
.sidebar {
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.brand h2 {
    font-family: 'Cinzel', serif;
    color: var(--blood-bright);
    font-size: 1.2rem;
    margin: 0;
    letter-spacing: 1px;
}

.logo-icon {
    color: var(--blood-bright);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(138, 3, 3, 0.1);
    color: var(--blood-bright);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(138, 3, 3, 0.2), transparent);
    color: var(--blood-bright);
    border-left: 3px solid var(--blood-bright);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.nav-item.text-danger {
    color: #ff6b6b;
    margin-top: auto;
}

.nav-item.text-danger:hover {
    background: rgba(255, 107, 107, 0.1);
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    display: grid;
    grid-template-rows: var(--header-height) 1fr;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at top right, rgba(138, 3, 3, 0.1), transparent 40%);
}

/* Top Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.page-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--text-main);
    margin: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--blood-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(138, 3, 3, 0.5);
}

/* --- DASHBOARD CONTENT --- */
.admin-tab {
    padding: 2rem;
    overflow-y: auto;
    display: none;
    /* Controlled by admin.js */
}

.admin-tab.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

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

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--blood-red), transparent);
    opacity: 0.5;
}

.dashboard-card h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.8rem;
}

/* --- BUTTONS & INPUTS Theme --- */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--blood-red);
    color: white;
    border: 1px solid transparent;
}

.btn-primary:hover {
    background: var(--blood-bright);
    box-shadow: 0 0 15px rgba(255, 50, 50, 0.3);
}

/* --- FORM ELEMENTS --- */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.8rem;
    border-radius: 6px;
    width: 100%;
    font-family: 'Montserrat', sans-serif;
    transition: border-color 0.3s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--blood-bright);
    box-shadow: 0 0 10px rgba(138, 3, 3, 0.2);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group {
    margin-bottom: 1.5rem;
}

/* Password Toggle Button */
.password-input-wrapper {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
    z-index: 1;
}

.password-toggle-btn:hover {
    color: var(--blood-bright, #ff3333);
}

.password-toggle-btn:focus {
    outline: 2px solid var(--blood-bright, #ff3333);
    outline-offset: 2px;
    border-radius: 4px;
}

.password-toggle-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.password-input-wrapper input[type="password"],
.password-input-wrapper input[type="text"] {
    padding-right: 2.5rem !important;
}

/* --- COLOR SWATCH GRID --- */
.color-swatch-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.color-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.color-section-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.swatch-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.75rem;
}

.color-swatch {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-swatch:hover {
    transform: scale(1.1);
    border-color: var(--blood-bright);
    box-shadow: 0 4px 12px rgba(255, 50, 50, 0.4);
    z-index: 1;
}

.color-swatch.active {
    border-color: var(--blood-bright);
    box-shadow: 0 0 0 2px var(--blood-red), 0 4px 12px rgba(255, 50, 50, 0.5);
}

/* --- VISUAL COLOR PICKER --- */
.visual-color-picker {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.color-picker-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.color-square {
    width: 100%;
    height: 200px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    position: relative;
    cursor: crosshair;
    background: linear-gradient(to right, #fff, transparent),
                linear-gradient(to bottom, transparent, #000);
    overflow: hidden;
}

.color-selector {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 4px rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}

.hue-slider-container {
    width: 100%;
    height: 20px;
    position: relative;
}

.hue-slider {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    background: linear-gradient(to right,
        #ff0000, #ff7f00, #ffff00, #7fff00, #00ff00, #00ff7f,
        #00ffff, #007fff, #0000ff, #7f00ff, #ff00ff, #ff007f, #ff0000
    );
    cursor: pointer;
    position: relative;
}

.hue-handle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 24px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 10;
}

.color-picker-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.color-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.color-input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0;
}

.rgb-input,
.hex-input {
    width: 100%;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    transition: border-color 0.3s ease;
}

.rgb-input:focus,
.hex-input:focus {
    outline: none;
    border-color: var(--blood-bright);
    box-shadow: 0 0 8px rgba(255, 50, 50, 0.3);
}

.hex-input:invalid {
    border-color: var(--blood-red);
}

.hex-group {
    grid-column: span 1;
}

.color-preview-large {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    flex-shrink: 0;
    transition: border-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* --- MODALS --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid var(--blood-red);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 0 30px rgba(138, 3, 3, 0.4);
    animation: slideDown 0.3s ease-out;
}

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

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

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

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

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

/* --- THEME PREVIEW --- */
.theme-preview-wrapper {
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.preview-header {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-muted);
}

.preview-box {
    background: black;
    padding: 2rem;
    border: 1px solid #333;
    border-radius: 8px;
    text-align: center;
}

.preview-box h1 {
    color: white;
    font-family: 'Cinzel', serif;
    margin-bottom: 0.5rem;
}

.preview-slogan {
    color: #aaa;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.preview-welcome {
    color: #ccc;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.6;
}

.preview-note {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
    font-style: italic;
}

/* --- UTILITIES --- */
.hidden {
    display: none !important;
}

.block {
    display: block;
}

.text-sm {
    font-size: 0.85rem;
}

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

.text-bright {
    color: var(--blood-bright);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-05 {
    margin-top: 0.5rem;
}

.mt-1 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 2rem;
}

.mt-auto {
    margin-top: auto;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-05 {
    margin-bottom: 0.5rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.ml-05 {
    margin-left: 0.5rem;
}

.p-1 {
    padding: 1rem;
}

.p-2 {
    padding: 2rem;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

.border-none {
    border: none !important;
}

.cursor-pointer {
    cursor: pointer;
}

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

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-end {
    display: flex;
    justify-content: flex-end;
    /* Note: justify-content for flex row */
    align-items: flex-end;
    /* Note: align-items for bars usually */
}

/* Specific component placeholders */
.chart-box {
    height: 180px;
    width: 100%;
}

.revenue-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 180px;
}

.map-placeholder {
    background: rgba(0, 0, 0, 0.5);
    height: 200px;
    color: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        display: flex;
    }

    /* Adjust top bar for toggle */
    .top-bar {
        padding-left: 1rem;
        gap: 1rem;
    }

    /* Show toggle */
    .admin-toggle {
        display: block !important;
        position: relative;
        z-index: 101;
    }
}

.admin-toggle {
    display: none;
}