/* ==========================================================================
   Design Tokens & Variables
   ========================================================================== */
:root {
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Global Accents */
    --color-primary: #3b82f6;
    --color-primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --color-success: #10b981;
    --color-error: #ef4444;
}

/* Thème Sombre */
.dark-theme {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #020617 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: rgba(15, 23, 42, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(255, 255, 255, 0.16);
    --btn-bg: rgba(30, 41, 59, 0.7);
    --btn-hover: rgba(51, 65, 85, 0.8);
    --btn-text: #f8fafc;
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    --border-light: rgba(255, 255, 255, 0.05);
}

/* Thème Clair */
.light-theme {
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(15, 23, 42, 0.06);
    --card-hover-border: rgba(15, 23, 42, 0.12);
    --btn-bg: rgba(255, 255, 255, 0.9);
    --btn-hover: rgba(226, 232, 240, 0.9);
    --btn-text: #0f172a;
    --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.1);
    --border-light: rgba(15, 23, 42, 0.05);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 2rem 1.5rem;
    transition: var(--transition-smooth);
    overflow-x: hidden;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition-smooth);
}

.glass:hover {
    border-color: var(--card-hover-border);
    transform: translateY(-2px);
}

.portal-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

/* ==========================================================================
   Header
   ========================================================================== */
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo {
    font-size: 2.5rem;
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.title-group h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.1rem;
}

/* Theme Switcher Button */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--btn-bg);
    border: 1px solid var(--card-border);
    color: var(--btn-text);
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-action:hover {
    background: var(--btn-hover);
    border-color: var(--card-hover-border);
    transform: translateY(-1px);
}

.sun-icon { display: none; }
.light-theme .sun-icon { display: none; }
.light-theme .moon-icon { display: block; }
.dark-theme .sun-icon { display: block; }
.dark-theme .moon-icon { display: none; }

/* ==========================================================================
   Overview Stats
   ========================================================================== */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
}

/* ==========================================================================
   Micro-apps Section & Grid
   ========================================================================== */
.apps-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    position: relative;
    padding-left: 0.75rem;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 4px;
    background: var(--color-primary-gradient);
    border-radius: 4px;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 0;
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* App Card styling */
.app-card {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.app-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.app-icon-wrapper {
    font-size: 2.25rem;
    background: rgba(255,255,255,0.03);
    padding: 0.5rem;
    border-radius: 16px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
}

.app-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-checking {
    background-color: var(--border-light);
    color: var(--text-secondary);
}

.status-online {
    background-color: rgba(16, 185, 129, 0.12);
    color: var(--color-success);
}

.status-offline {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--color-error);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

.status-dot-pulse {
    animation: badge-pulse 1.5s infinite;
}

@keyframes badge-pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

.app-details h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.app-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.app-actions {
    margin-top: auto;
    display: flex;
    gap: 0.75rem;
}

.btn-open {
    flex-grow: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--color-primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
    transition: var(--transition-smooth);
}

.btn-open:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.35);
}

.btn-api {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--btn-bg);
    border: 1px solid var(--card-border);
    color: var(--btn-text);
    border-radius: 14px;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.btn-api:hover {
    background: var(--btn-hover);
    border-color: var(--card-hover-border);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.portal-footer {
    border-top: 1px solid var(--border-light);
    padding-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
}
