/* ============================================================================
   Nexura Platform Shell — CSS

   The unified styling for the platform shell: sidebar, topbar, dashboard,
   and login overlay. Uses CSS custom properties for dark/light theming.

   Naming convention: nx- prefix (Nexura)
   ============================================================================ */

/* ── CSS Custom Properties (Theme) ──────────────────────────────────── */
:root {
    /* Dark theme (default) */
    --nx-bg: #0f172a;
    --nx-bg-surface: #1e293b;
    --nx-bg-elevated: #293548;
    --nx-border: rgba(255,255,255,0.06);
    --nx-text: #e2e8f0;
    --nx-text-muted: #94a3b8;
    --nx-text-bright: #f8fafc;
    --nx-accent: #3b82f6;
    --nx-accent-hover: #2563eb;
    --nx-sidebar-bg: #0c1222;
    --nx-sidebar-hover: rgba(255,255,255,0.05);
    --nx-sidebar-active: rgba(59,130,246,0.12);
    --nx-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

/* Light theme override */
[data-theme="light"] {
    --nx-bg: #f1f5f9;
    --nx-bg-surface: #ffffff;
    --nx-bg-elevated: #f8fafc;
    --nx-border: #e2e8f0;
    --nx-text: #1e293b;
    --nx-text-muted: #64748b;
    --nx-text-bright: #0f172a;
    --nx-sidebar-bg: #ffffff;
    --nx-sidebar-hover: rgba(0,0,0,0.04);
    --nx-sidebar-active: rgba(59,130,246,0.08);
    --nx-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ── Reset & Base ───────────────────────────────────────────────────── */
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    background: var(--nx-bg);
    color: var(--nx-text);
    overflow: hidden; /* Shell controls scrolling */
    height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ── Shell Layout ───────────────────────────────────────────────────── */
/* Sidebar (240px) + Main (rest) */
#nexura-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ── Sidebar ────────────────────────────────────────────────────────── */
.nx-sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--nx-sidebar-bg);
    border-right: 1px solid var(--nx-border);
    display: flex;
    flex-direction: column;
    transition: width 0.2s, min-width 0.2s;
    z-index: 100;
}

/* Logo area */
.nx-sidebar__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--nx-border);
}

.nx-sidebar__logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--nx-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.nx-sidebar__logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--nx-text-bright);
}

/* Navigation */
.nx-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.nx-sidebar__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--nx-text-muted);
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 2px;
}

.nx-sidebar__item:hover {
    background: var(--nx-sidebar-hover);
    color: var(--nx-text);
}

.nx-sidebar__item--active {
    background: var(--nx-sidebar-active);
    color: var(--nx-accent);
    font-weight: 600;
}

.nx-sidebar__item ion-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* Separator label */
.nx-sidebar__separator {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--nx-text-muted);
    opacity: 0.5;
    padding: 16px 12px 6px;
}

/* Sidebar footer: user info */
.nx-sidebar__footer {
    padding: 12px;
    border-top: 1px solid var(--nx-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nx-sidebar__user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.nx-sidebar__user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--nx-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.nx-sidebar__user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--nx-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nx-sidebar__user-tenant {
    font-size: 10px;
    color: var(--nx-text-muted);
}

.nx-sidebar__logout {
    background: none;
    border: none;
    color: var(--nx-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    font-size: 18px;
    display: flex;
}

.nx-sidebar__logout:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* ── Main Content Area ──────────────────────────────────────────────── */
.nx-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar */
.nx-topbar {
    height: 52px;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--nx-border);
    background: var(--nx-bg-surface);
}

.nx-topbar__toggle {
    display: none; /* Show on mobile */
    background: none;
    border: none;
    color: var(--nx-text);
    font-size: 22px;
    cursor: pointer;
}

.nx-topbar__search {
    flex: 1;
    max-width: 500px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--nx-bg);
    border: 1px solid var(--nx-border);
    border-radius: 8px;
    padding: 6px 12px;
}

.nx-topbar__search ion-icon {
    color: var(--nx-text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

.nx-topbar__search input {
    background: none;
    border: none;
    color: var(--nx-text);
    font-size: 13px;
    width: 100%;
    outline: none;
}

.nx-topbar__search input::placeholder {
    color: var(--nx-text-muted);
}

.nx-topbar__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nx-topbar__btn {
    background: none;
    border: none;
    color: var(--nx-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    position: relative;
}

.nx-topbar__btn:hover {
    background: var(--nx-sidebar-hover);
    color: var(--nx-text);
}

.nx-topbar__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Content Area ───────────────────────────────────────────────────── */
.nx-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Dashboard ──────────────────────────────────────────────────────── */
.nx-dashboard__title {
    font-size: 24px;
    font-weight: 800;
    color: var(--nx-text-bright);
    margin-bottom: 6px;
}

.nx-dashboard__subtitle {
    font-size: 14px;
    color: var(--nx-text-muted);
    margin-bottom: 24px;
}

.nx-dashboard__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.nx-dashboard__card {
    background: var(--nx-bg-surface);
    border: 1px solid var(--nx-border);
    border-radius: 14px;
    padding: 20px;
    transition: all 0.15s;
    cursor: pointer;
}

.nx-dashboard__card:hover {
    transform: translateY(-2px);
    box-shadow: var(--nx-shadow);
    border-color: var(--nx-accent);
}

.nx-dashboard__card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.nx-dashboard__card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--nx-text-bright);
    margin-bottom: 4px;
}

.nx-dashboard__card-desc {
    font-size: 12px;
    color: var(--nx-text-muted);
}

/* ── Login Overlay ──────────────────────────────────────────────────── */
.nx-login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--nx-bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nx-login-card {
    background: var(--nx-bg-surface);
    border: 1px solid var(--nx-border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--nx-shadow);
}

.nx-login-card__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.nx-login-card__logo h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--nx-text-bright);
}

.nx-login-card__subtitle {
    font-size: 13px;
    color: var(--nx-text-muted);
    margin-bottom: 24px;
}

.nx-login-card__field {
    margin-bottom: 14px;
}

.nx-login-card__field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--nx-text);
    margin-bottom: 4px;
}

.nx-login-card__field input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--nx-border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--nx-bg);
    color: var(--nx-text);
    outline: none;
}

.nx-login-card__field input:focus {
    border-color: var(--nx-accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.nx-login-card__error {
    background: rgba(239,68,68,0.08);
    color: #f87171;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(239,68,68,0.25);
    border-left: 3px solid #ef4444;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nx-login-card__error::before {
    content: "⚠";
    font-size: 16px;
    flex-shrink: 0;
}

.nx-login-card__btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: var(--nx-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.nx-login-card__btn:hover {
    background: var(--nx-accent-hover);
}

.nx-login-card__btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Mobile Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .nx-sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        bottom: 0;
        transition: left 0.2s;
        z-index: 200;
    }
    .nx-sidebar.nx-sidebar--open {
        left: 0;
    }
    .nx-topbar__toggle {
        display: flex;
    }
}
