/* ===================================================================
   Johny Labs App Portal — Styles
   Matching the main johnylabs.com.au design system
   =================================================================== */

/* --- Variables --- */
:root {
    --accent: #3b82f6;
    --accent-secondary: #06b6d4;
    --gradient: linear-gradient(135deg, #3b82f6, #06b6d4);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-navbar: rgba(10, 14, 23, 0.95);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --shadow: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-navbar: rgba(255, 255, 255, 0.95);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: rgba(30, 41, 59, 0.1);
    --shadow: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .logo-dark { display: block; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="light"] .logo-light { display: block; }

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 16px 0;
    background: var(--bg-navbar);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-img {
    height: 60px;
    width: auto;
    background: transparent;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.last-login {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    white-space: nowrap;
}

/* --- Theme Toggle --- */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
    cursor: pointer;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 28px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gradient);
    border-radius: 50%;
    transition: var(--transition);
}

.theme-toggle input:checked + .toggle-slider::before {
    left: calc(100% - 25px);
}

.toggle-icon {
    font-size: 0.75rem;
    z-index: 1;
}

.toggle-icon svg {
    width: 14px;
    height: 14px;
    fill: var(--text-secondary);
}

/* --- Logout Button --- */
.logout-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.logout-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.logout-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding-top: 120px;
    padding-bottom: 80px;
}

.page-header {
    text-align: center;
    margin-bottom: 48px;
}

.page-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* --- App Grid --- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* --- App Tile (Card) --- */
.app-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.app-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient);
    opacity: 0;
    transition: var(--transition);
}

.app-tile:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 16px 40px var(--shadow);
}

.app-tile:hover::before {
    opacity: 1;
}

.app-tile:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.app-tile:active {
    transform: translateY(-1px);
}

.tile-icon {
    font-size: 2.25rem;
    line-height: 1;
    margin-bottom: 4px;
    color: var(--accent);
}

.tile-icon svg {
    width: 36px;
    height: 36px;
    display: block;
}

.tile-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* --- Error / Access Denied / No Apps --- */
.error-container,
.access-denied,
.no-apps-message {
    text-align: center;
    padding: 4rem 1.5rem;
    max-width: 480px;
    margin: 2rem auto;
}

.error-container h2,
.access-denied h2,
.no-apps-message h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.error-container p,
.access-denied p,
.no-apps-message p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.retry-link {
    display: inline-block;
    background: var(--gradient);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.retry-link:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* --- Footer --- */
.footer {
    padding: 40px 0;
    text-align: center;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.footer-logo {
    height: 24px;
    opacity: 0.7;
    background: transparent;
}

.footer-copy {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* --- Noscript fallback --- */
.noscript-message {
    text-align: center;
    padding: 4rem 1.5rem;
    max-width: 480px;
    margin: 6rem auto 0;
}

.noscript-message h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.noscript-message p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .logo-img {
        height: 44px;
    }

    .page-content {
        padding-top: 100px;
        padding-bottom: 60px;
    }

    .page-header {
        margin-bottom: 32px;
    }

    .app-grid {
        grid-template-columns: 1fr;
    }

    .user-info {
        display: none;
    }

    .last-login {
        display: none !important;
    }
}
