:root {
    --brand-blue: #003399;      
    --brand-red: #b30000;       
    --brand-lime: #abcd16;      
    --brand-purple: #7c3aed;
    --bg-light: #fafcff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(203, 213, 225, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-light);
    /* Animated Aurora/Mesh Gradient Background */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(0, 51, 153, 0.04), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(179, 0, 0, 0.03), transparent 30%),
        radial-gradient(circle at 50% 80%, rgba(171, 205, 22, 0.04), transparent 40%);
    background-attachment: fixed;
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout & Structural */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0 4rem;
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 70px;
    align-items: center;
}

.header-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    bottom: 0;
    z-index: 1000;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.2s ease;
}
.logo:hover {
    transform: scale(1.02);
}

.app-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-dark);
    border-left: 2px solid var(--border-color);
    padding-left: 0.75rem;
    letter-spacing: -0.5px;
}

.header-right-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Advanced Buttons */
.btn-portal-back {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-dark);
    padding: 0.5rem 1.25rem;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    font-family: inherit;
}
.btn-portal-back:hover {
    background: rgba(15, 23, 42, 0.04);
    border-color: var(--brand-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-blue), #002266);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.85rem 1.75rem;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(0, 51, 153, 0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 51, 153, 0.4);
    background: linear-gradient(135deg, #0044cc, var(--brand-blue));
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-copy {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0 1rem;
    font-weight: 700;
    color: var(--brand-blue);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Premium Workspace Panels */
.workspace-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.workspace-panel:hover {
    box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

/* Main Container */
.app-container {
    flex: 1;
    padding: 3rem 4rem;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.5s ease-out;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 2rem 1rem 4rem;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1.15;
    margin-bottom: 1.25rem;
    letter-spacing: -1.5px;
}
.hero-title span {
    background: linear-gradient(135deg, var(--brand-red), #ff3333);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 650px;
    margin: 0 auto 3rem;
    line-height: 1.6;
}

/* Floating Advantage Pills */
.tmpl-card {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.adv-pill {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.3s, box-shadow 0.3s;
}
.adv-pill i {
    color: var(--brand-blue);
    font-size: 1.2rem;
}
.adv-pill:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-color: var(--brand-blue);
}

.stat-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--brand-blue);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="url"], input[type="text"], input[type="password"], input[type="color"], select {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    font-size: 1rem;
    outline: none;
    background: rgba(255,255,255,0.9);
    color: var(--text-dark);
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02) inset;
}

input:focus, select:focus {
    border-color: var(--brand-blue);
    background: white;
    box-shadow: 0 0 0 4px rgba(0, 51, 153, 0.1), 0 2px 4px rgba(0,0,0,0.02) inset;
}

/* Layout Utilities */
.hidden { display: none !important; }

/* Feedback Boxes */
.error-box, .result-box {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    animation: slideDown 0.3s ease-out;
}
.error-box {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #f87171;
}
.result-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.success-text {
    color: #15803d;
    font-weight: 800;
}
.copy-url-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Tabs */
.btn-tab {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.75rem 1.25rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
.btn-tab:hover { color: var(--text-dark); }
.active-tab {
    color: var(--brand-blue);
    border-bottom: 3px solid var(--brand-blue);
}

/* Tables */
table th {
    color: var(--text-muted);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}
table td {
    color: var(--text-dark);
}

.btn-danger {
    background: rgba(179, 0, 0, 0.05);
    border: 1px solid rgba(179, 0, 0, 0.2);
    color: var(--brand-red);
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-danger:hover {
    background: var(--brand-red);
    color: white;
}

/* Modal */
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}
.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    background: white;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.btn-icon:hover { color: var(--brand-red); }

/* Documentation Specifics */
.api-docs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
    margin-top: 2rem;
}

@media (max-width: 1024px) {
    .api-docs-grid {
        grid-template-columns: 1fr;
    }
}

.api-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.85rem;
}

.api-table th {
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    padding: 0.5rem 0;
    color: var(--text-dark);
}

.api-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
    vertical-align: top;
}

.api-badge {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    color: var(--brand-blue);
    font-weight: 700;
}

.code-window {
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.3);
}

.code-header {
    background: #1e293b;
    padding: 0.75rem 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border-bottom: 1px solid #334155;
}

.code-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.code-content {
    padding: 1.5rem;
    color: #e2e8f0;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
}

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

/* =======================================
   4. Authenticated Portal (Sidebar Layout)
   ======================================= */
.portal-layout {
    display: flex;
    height: calc(100vh - 216px); /* 70px header + 50px footer + 6rem padding */
    background: #f1f5f9;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
}

.portal-sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 3px solid transparent;
}

.sidebar-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.sidebar-item:hover {
    background: #f8fafc;
    color: var(--brand-blue);
}

.sidebar-item:hover i {
    color: var(--brand-blue);
}

.sidebar-item.active {
    background: #f0fdf4;
    color: var(--brand-blue);
    border-left-color: var(--brand-red);
}

.sidebar-item.active i {
    color: var(--brand-red);
}

.portal-main {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.portal-panel {
    animation: fadeIn 0.3s ease-out;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #mobileMenuBtn { display: block !important; }
    
    .portal-sidebar {
        position: fixed;
        left: -300px;
        top: 60px;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    }
    
    .portal-sidebar.open {
        left: 0;
    }
    
    .portal-main {
        padding: 1rem;
    }

    .table-container {
        overflow-x: auto;
    }

    .stats-grid, .chart-container {
        flex-direction: column;
    }
    
    .hero-title {
        font-size: 2rem !important;
    }
    
    .config-header-panel form .form-row {
        flex-direction: column;
    }
    
    .config-header-panel form > div > div {
        grid-template-columns: 1fr !important;
    }
}

