/* ════════════════════════════════════════════════════
   Patent Docket System – Premium Design System
   ════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
    /* Primary – Deep Obsidian / Indigo */
    --primary-h: 226;
    --primary-s: 80%;
    --primary-l: 50%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-glow: hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.4);
    
    /* Sidebar – Dark Obsidian */
    --sidebar-bg: #0f172a;
    --sidebar-accent: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    
    /* Backgrounds */
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.85);
    
    /* Neutrals */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    /* Layout */
    --sidebar-w: 260px;
    --sidebar-collapsed-w: 72px;
    --topbar-h: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    /* Transitions */
    --drift: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-label {
    font-family: 'Outfit', sans-serif;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #4338ca;
}

/* ── App Shell ───────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-base);
}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--drift);
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-w);
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    overflow: hidden;
    white-space: nowrap;
    transition: padding 0.2s;
}

.sidebar-collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
}

.brand-icon {
    font-size: 1.8rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
    flex-shrink: 0;
}

.brand-label {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    transition: opacity 0.2s, width 0.2s;
}

.sidebar-collapsed .sidebar-brand .brand-label {
    opacity: 0;
    width: 0;
    margin: 0;
    pointer-events: none;
}

/* ── Navigation ──────────────────────────────────── */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.65rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #475569;
    padding: 1.5rem 1rem 0.6rem;
    transition: opacity 0.2s;
}

.sidebar-collapsed .nav-section-label {
    opacity: 0;
}

.nav-group {
    margin-bottom: 0.25rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    user-select: none;
}

.nav-group-header:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-text-active);
}

.nav-group-header .chevron {
    margin-left: auto;
    font-size: 1.1rem;
    transition: transform 0.3s ease, opacity 0.2s;
    color: #475569;
}

.sidebar-collapsed .nav-group-header .chevron {
    opacity: 0;
    width: 0;
    margin: 0;
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    opacity: 0;
    padding-left: 0.5rem;
}

.nav-group.expanded .nav-group-items {
    max-height: 500px; /* Large enough to fit items */
    opacity: 1;
    padding-top: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.15rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-group-items .nav-link {
    padding-left: 3rem; /* Indent sub-links */
}

.nav-link .material-icons {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background: linear-gradient(90deg, var(--primary), #6366f1);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-label {
    transition: opacity 0.2s, width 0.2s;
    overflow: hidden;
}

.sidebar-collapsed .nav-link .nav-label,
.sidebar-collapsed .nav-group-header .nav-label {
    opacity: 0;
    width: 0;
    margin: 0;
    pointer-events: none;
}

.sidebar-collapsed .nav-link,
.sidebar-collapsed .nav-group-header {
    justify-content: center;
    padding: 0.75rem 0;
}

.sidebar-collapsed .nav-group-items .nav-link {
    padding-left: 0;
}

/* ── Topbar ──────────────────────────────────────── */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: var(--border);
    color: var(--text-main);
}

.search-container {
    flex: 1;
    max-width: 500px;
}

.search-container form {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container input {
    width: 100%;
    background: #f1f5f9;
    border: 1px solid transparent;
    padding: 0.6rem 1rem 0.6rem 3rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-container input:focus {
    background: #fff;
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.search-container .material-icons {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

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

/* ── Content Area ────────────────────────────────── */
.main-content {
    padding: 2.5rem;
    max-width: 1600px;
}

/* ── Premium Elements ────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 6px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px var(--primary-glow);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -var(--sidebar-w);
        height: 100vh;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .mobile-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(4px);
        z-index: 999;
        display: none;
    }
    
    .mobile-overlay.visible {
        display: block;
    }
}

/* ── Fix for the user UI ── */
/* If grid fails, we use flexbox as above. To ensure it doesn't look like original screenshot: */
.sidebar .nav-link {
    color: var(--sidebar-text) !important;
}

/* Ensuring material icons scale */
.material-icons {
    user-select: none;
}

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

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
}

/* ── Tables ───────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 1rem;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover {
    background: rgba(248, 250, 252, 0.8);
}

table a {
    color: #334155; /* Slate 700 */
    font-weight: 500;
}

table a:hover {
    color: var(--primary);
}

.clickable-row {
    cursor: pointer;
    transition: background 0.2s;
}

.clickable-row:hover {
    background: #f1f5f9;
}

.status-badge {
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    background: #f1f5f9;
    color: #64748b;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}