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

:root {
    --bg-base: #060913;
    --bg-panel: rgba(16, 23, 41, 0.7);
    --bg-surface: #101729;
    --bg-card: #152039;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(99, 102, 241, 0.15);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dark: #64748b;
    
    --primary: #6366f1; /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.35);
    --secondary: #0ea5e9; /* Sky Blue */
    --secondary-glow: rgba(14, 165, 233, 0.35);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.2);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --info: #3b82f6;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease-out;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
}

/* Background Gradients */
.bg-glows {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.glow-1 {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(6, 9, 19, 0) 70%);
    filter: blur(80px);
}

.glow-2 {
    position: absolute;
    bottom: -20%;
    right: -10%;
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.12) 0%, rgba(6, 9, 19, 0) 70%);
    filter: blur(80px);
}

/* Main Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    backdrop-filter: blur(10px);
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    backdrop-filter: blur(20px);
    overflow: hidden;            /* scroll lives on .sidebar-nav */
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

/* Scrollable middle region between logo and footer. */
.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;               /* required for overflow inside flex */
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;      /* room for the scrollbar */
    margin-right: -0.25rem;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.45);
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    transition: var(--transition-smooth);
}

.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: white;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(14, 165, 233, 0.05));
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-item.active svg {
    color: var(--primary);
}

.sidebar-footer {
    margin-top: 1rem;
    flex-shrink: 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
    animation: pulse 2s infinite;
}

.status-text h4 {
    font-size: 0.85rem;
    font-weight: 600;
}

.status-text p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

header.content-header {
    height: 80px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3rem;
    background: rgba(6, 9, 19, 0.5);
    backdrop-filter: blur(10px);
}

.header-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.port-badge {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 700;
}

/* Tab Containers */
.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 3rem;
    display: none;
}

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

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

.dashboard-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.dashboard-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card-decor {
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1.25rem;
}

.card-title-row svg {
    color: var(--primary);
    width: 20px;
    height: 20px;
}

.card-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, white, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.card-sub span {
    color: var(--success);
    font-weight: 600;
}

/* Forms Styling */
.form-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    max-width: 850px;
    margin: 0 auto;
    position: relative;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.form-group-full {
    grid-column: span 2;
}

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

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

input, select, textarea {
    background-color: rgba(6, 9, 19, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background-color: rgba(6, 9, 19, 0.6);
}

input::placeholder, textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.btn-container {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.85rem 2rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Table Design */
.table-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 2rem;
}

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

.table-header-row h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 450px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem 2rem;
    font-size: 0.9rem;
}

th {
    background-color: rgba(6, 9, 19, 0.3);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
}

tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    transition: var(--transition-fast);
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

td {
    color: var(--text-main);
}

/* Badges */
.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-pending {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-failed {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Live Logs Viewer */
.logs-panel {
    background: #040711;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 550px;
}

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

.logs-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.logs-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
}

.log-entry {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.02);
}

.log-entry.incoming {
    border-left-color: var(--secondary);
}

.log-entry.error {
    border-left-color: var(--danger);
}

.log-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: flex;
    gap: 1rem;
}

.log-path {
    font-weight: 600;
    color: var(--text-main);
}

.log-body {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

/* Batch Builder Styles */
.batch-builder-row {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    position: relative;
}

.batch-builder-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.batch-remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition-fast);
}

.batch-remove-btn:hover {
    color: var(--danger);
}

/* QR Code Display */
.qr-result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.01);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.qr-box {
    width: 250px;
    height: 250px;
    background: white;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.qr-placeholder {
    font-size: 0.85rem;
    color: #000;
    text-align: center;
    font-weight: 600;
}

.qr-raw-string {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    background-color: rgba(0,0,0,0.5);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    color: var(--secondary);
    border: 1px solid rgba(14, 165, 233, 0.15);
    max-width: 100%;
    word-break: break-all;
    text-align: center;
}

/* Webhook Simulator Styles */
.sim-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;       /* don't stretch short columns */
}

/* When .sim-grid is used by the Gateway Client tab, give each column
   some vertical breathing room between stacked panels. */
.sim-grid > div {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sim-grid .form-panel {
    margin: 0;
    max-width: 100%;
}

/* Tighten the dashboard-grid used inside the Gateway Client status card
   so the four badges align as a uniform 2x2 block. */
.sim-grid .dashboard-grid {
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    grid-template-columns: 1fr 1fr;
}

.sim-grid .dashboard-card {
    padding: 1rem 1.1rem;
}

.sim-grid .dashboard-card .card-title-row {
    margin-bottom: 0.35rem;
}

.sim-tx-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 550px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.sim-tx-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sim-tx-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(255, 255, 255, 0.02);
}

.sim-tx-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), transparent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.1);
}

.sim-details {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 4rem 2rem;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); opacity: 0.5; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Loading Spinners */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Utility classes */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Custom navigation adjustments */
.nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
    transform: translateX(4px);
}

.nav-item.active {
    transform: translateX(4px);
}

/* Card gradient border animations */
.dashboard-card {
    position: relative;
    z-index: 1;
}

.dashboard-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: linear-gradient(135deg, transparent, transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    transition: var(--transition-smooth);
    z-index: -1;
}

.dashboard-card:hover::after {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

/* Settings special cards */
#card-access-status.valid::after {
    background: linear-gradient(135deg, var(--success), transparent);
}

#card-access-status.expired::after {
    background: linear-gradient(135deg, var(--danger), transparent);
}

#card-refresh-status.valid::after {
    background: linear-gradient(135deg, var(--success), transparent);
}

#card-refresh-status.expired::after {
    background: linear-gradient(135deg, var(--danger), transparent);
}

.btn-primary svg {
    margin-right: 0.25rem;
}

/* Anchor tag buttons */
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
