@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #020617;
    --bg-mesh: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%), 
               radial-gradient(at 50% 0%, rgba(14, 165, 233, 0.15) 0px, transparent 50%),
               radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    --bg-card: rgba(15, 23, 42, 0.75);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary: #0ea5e9;
    --accent: #a855f7;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --input-focus: rgba(99, 102, 241, 0.2);
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }

body {
    background-color: var(--bg-main);
    background-image: var(--bg-mesh);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

.app-wrapper { flex: 1; display: flex; flex-direction: column; }
.container { max-width: 1240px; width: 100%; margin: 0 auto; padding: 0 1.5rem; }

/* PROFESSIONAL HEADER */
header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 0;
}

.header-inner { display: flex; justify-content: space-between; align-items: center; }
.logo-area { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.logo-icon {
    width: 42px; height: 42px; border-radius: 12px;
    background: rgba(255, 255, 255, 0.03); 
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.logo-icon::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(45deg); animation: shimmer 3s infinite;
}

@keyframes shimmer { 0% { transform: translateX(-100%) rotate(45deg); } 100% { transform: translateX(100%) rotate(45deg); } }

.logo-icon img { height: 28px; width: 28px; object-fit: contain; filter: drop-shadow(0 0 8px var(--primary-glow)); }

.logo-area:hover .logo-icon { transform: scale(1.05); border-color: var(--primary); box-shadow: 0 0 20px rgba(99, 102, 241, 0.2); }

/* CONTENT GRID */
.main-layout { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; margin-top: 2rem; }
@media (max-width: 1024px) { 
    .main-layout { grid-template-columns: 1fr; margin-top: 1rem; } 
    .sidebar-col { order: 1; margin-top: 2rem; } /* Pushes Telemetry to the bottom on mobile */
}

/* PREMIUM CARDS */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 2rem;
}
.glass-card:hover {
    box-shadow: 0 35px 60px -12px rgba(0, 0, 0, 0.7);
}

.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.card-header-title { display: flex; align-items: center; gap: 0.6rem; font-size: 1rem; font-weight: 800; color: #fff; }

/* TABS */
.nav-tabs { display: flex; gap: 0.5rem; background: rgba(2, 6, 23, 0.6); padding: 0.4rem; border-radius: var(--radius-lg); margin-bottom: 1.5rem; }
.tab-link {
    flex: 1; padding: 0.75rem; font-size: 0.75rem; font-weight: 800; color: var(--text-muted);
    cursor: pointer; border-radius: var(--radius-md); transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    border: none; background: transparent; text-transform: uppercase;
}
.tab-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }

/* FORMS */
.multi-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 640px) { .multi-col { grid-template-columns: 1fr; } }

.field-wrap { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.field-label { font-size: 0.65rem; font-weight: 900; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

input, textarea {
    width: 100%; padding: 0.85rem 1rem; background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: #fff; font-size: 0.9rem; transition: border-color 0.2s;
}

.password-wrap { position: relative; width: 100%; }
.password-toggle {
    position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%);
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; padding: 0.25rem; display: flex; align-items: center;
    transition: color 0.2s;
}
.password-toggle:hover { color: #fff; }

input:focus, textarea:focus { outline: none; border-color: var(--primary); }

/* ASSETS */
.asset-pill {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; background: rgba(255,255,255,0.02);
    border: 1px solid var(--border); border-radius: 12px;
}
.asset-name { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; font-weight: 600; }

/* TABLE FIX */
.table-scroll { 
    margin-top: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-lg); 
    max-height: 480px; overflow-y: auto; overflow-x: auto; background: rgba(2, 6, 23, 0.4);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { background: rgba(15, 23, 42, 0.9); padding: 0.85rem 1rem; text-align: left; font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
td { padding: 0.85rem 1rem; font-size: 0.85rem; border-top: 1px solid rgba(255,255,255,0.03); }

/* SIDEBAR MANUAL & TELEMETRY */
.help-box { 
    margin-top: 1.5rem; padding: 1.5rem; 
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(14, 165, 233, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.15); border-radius: var(--radius-xl);
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.05);
}
.help-title { 
    font-size: 0.7rem; font-weight: 950; color: #fff; margin-bottom: 1.5rem; 
    text-transform: uppercase; display: flex; align-items: center; gap: 0.6rem;
    letter-spacing: 0.15em; opacity: 0.8;
}
.help-row { margin-bottom: 1.5rem; position: relative; padding-left: 1.25rem; }
.help-row::before {
    content: ''; position: absolute; left: 0; top: 0.25rem; width: 4px; height: 12px;
    background: var(--primary); border-radius: 10px; opacity: 0.5;
}
.help-row b { font-size: 0.8rem; color: #fff; display: block; margin-bottom: 0.35rem; font-weight: 800; letter-spacing: -0.01em; }
.help-row p { font-size: 0.75rem; color: var(--text-muted); line-height: 1.6; font-weight: 500; }

#telemetry-stats { display: flex; flex-direction: column; gap: 1.5rem; margin-bottom: 2rem; }
.tele-pill {
    display: flex; justify-content: space-between; align-items: center; 
    padding: 1rem 1.25rem; background: rgba(2, 6, 23, 0.4);
    border: 1px solid var(--border); border-radius: 14px;
}
.tele-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; }
.tele-val { font-size: 1.25rem; font-weight: 900; color: #fff; letter-spacing: -0.02em; }

.infra-badge {
    font-size: 0.6rem; font-weight: 950; background: var(--success); color: #fff; 
    padding: 5px 12px; border-radius: 6px; box-shadow: 0 0 15px rgba(16,185,129,0.4);
    animation: pulse 2s infinite ease-in-out;
}
@keyframes pulse { 
    0%, 100% { opacity: 1; transform: scale(1); } 
    50% { opacity: 0.9; transform: scale(1.02); box-shadow: 0 0 20px rgba(16,185,129,0.6); } 
}

/* GLOBAL ELEMENTS */
.btn { 
    display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
    padding: 0.9rem 1.75rem; border-radius: var(--radius-md); font-weight: 800;
    font-size: 0.75rem; cursor: pointer; border: none; text-transform: uppercase;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.05em;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); filter: brightness(1); }
.btn-primary { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); 
    color: #fff; box-shadow: 0 8px 24px -6px var(--primary-glow); 
}
.btn-outline { 
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid var(--border); 
    color: var(--text-main); 
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--glass-border); }
.btn-icon-only { width: 34px; height: 34px; background: rgba(239, 68, 68, 0.05); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.1); border-radius: 8px; cursor: pointer; }

/* MODALS & OVERLAYS */
#modal-shell {
    position: fixed; inset: 0; background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(15px); z-index: 2000; display: none;
    align-items: center; justify-content: center; padding: 1.5rem;
}
.modal-body { background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); max-width: 420px; width: 100%; padding: 2.5rem; text-align: center; }

/* FULL-SCREEN LOADER (CENTERED) */
#loading-overlay {
    position: fixed; inset: 0; background: rgba(2, 6, 23, 0.95);
    z-index: 3000; display: none; flex-direction: column;
    align-items: center; justify-content: center; backdrop-filter: blur(10px);
}
.spinner { width: 48px; height: 48px; border: 3px solid rgba(255,255,255,0.05); border-top-color: var(--primary); border-radius: 50%; animation: rot .7s linear infinite; margin-bottom: 1.5rem; }
@keyframes rot { to { transform: rotate(360deg); } }

#toast-tray { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 4000; display: flex; flex-direction: column; gap: 0.75rem; pointer-events: none; }
.platinum-toast { background: #0f172a; border: 1px solid var(--glass-border); padding: 0.85rem 1.25rem; border-radius: 12px; display: flex; align-items: center; gap: 0.75rem; color: #fff; font-size: 0.85rem; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,0.5); pointer-events: auto; }

/* FOOTER */
footer { padding: 2.5rem 0; border-top: 1px solid var(--border); background: rgba(15, 23, 42, 0.5); margin-top: auto; }
.footer-wrap { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
@media (max-width: 600px) { .footer-wrap { justify-content: center; text-align: center; } }
.foot-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; font-size: 0.9rem; }
.foot-note { font-size: 0.6rem; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; }

.animate-up { animation: fadeInUp 0.4s ease forwards; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* HIGHLIGHT ARCHITECT */
.template-architect-wrapper {
    position: relative;
    width: 100%;
}

.template-backdrop, 
#body.highlight-mode {
    font-family: inherit !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    padding: 0.85rem 1rem !important;
    margin: 0 !important;
    border-radius: var(--radius-md) !important;
    box-sizing: border-box !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
}

.template-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
    color: var(--text-main) !important;
    pointer-events: none;
    overflow-y: auto !important; /* Matches textarea scrolling perfectly */
    background: rgba(2, 6, 23, 0.6) !important;
    border: 1px solid transparent !important;
}

.template-backdrop mark.hr-highlight {
    background-color: rgba(99, 102, 241, 0.15);
    color: var(--primary) !important;
    border-radius: 4px;
}

.template-backdrop mark.company-highlight {
    background-color: rgba(14, 165, 233, 0.15);
    color: var(--secondary) !important;
    border-radius: 4px;
}

#body.highlight-mode {
    position: relative;
    z-index: 2;
    background-color: transparent !important;
    color: transparent !important;
    caret-color: #fff !important;
    border: 1px solid var(--border) !important;
    resize: none !important;
    overflow-y: auto !important;
}
