@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
    --apple-blue: #007AFF;
    --bg-app: #F2F2F7;
    --bg-panel: #FFFFFF;
    --bg-hover: #F3F4F6;
    --border: #E5E5EA;
    --accent: #007AFF;
    --text-main: #000000;
    --text-muted: #6B7280;
}

/* --- GLOBAL LAYOUT --- */
body {
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden; /* Prevent body scroll, let containers scroll */
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
}

/* Header is flex-none (fixed height), Dashboard takes the rest */
header {
    flex: none;
}

/* --- DASHBOARD GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 420px 1fr; /* Feed | Inspector */
    flex: 1;          /* Take all remaining vertical space */
    min-height: 0;    /* Critical: allows children to scroll */
    width: 100vw;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1.5rem;
    padding: 1.5rem;
    padding-bottom: 0; /* Remove bottom padding to let panels flush to bottom if needed */
    position: relative;
}

/* --- FEED PANEL (Left) --- */
.feed-panel {
    display: flex;
    flex-direction: column;
    height: 100%;     /* Fill the grid cell exactly */
    overflow: hidden; /* Internal scrolling only */
    gap: 1rem;
    min-width: 0;
}

.feed-header {
    padding-bottom: 0.5rem;
    flex-shrink: 0;
}

.feed-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem; 
    padding-bottom: 4rem; /* Extra space at bottom for scrolling */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    
    /* Hide Scrollbar but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE 10+ */
}
.feed-list::-webkit-scrollbar { 
    display: none; /* Chrome/Safari */
}

/* FEED ITEM CARD */
.feed-item {
    background-color: var(--bg-panel);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
}

.feed-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    border-color: var(--accent);
}

.feed-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0,0,0,0.1);
    background-color: #F8FAFC;
    z-index: 10;
}

/* --- INSPECTOR PANEL (Right) --- */
.inspector-panel {
    background-color: var(--bg-panel);
    border-radius: 1.25rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    height: 100%;      /* Fill grid cell */
    overflow: hidden;  /* Prevent outer scroll */
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: 1.5rem; /* Add margin to lift off bottom of screen */
}

/* The scrollable container inside the inspector */
.inspector-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 6rem; /* Huge padding to ensure bottom content is visible */
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.stat-box {
    background-color: var(--bg-panel);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    text-align: center;
}

.grade-badge-lg {
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        padding: 0;
        gap: 0;
        display: block; /* Switch to block to handle absolute positioning better on mobile */
    }

    .feed-panel {
        padding: 1rem;
        width: 100%;
        height: 100%; /* Fill body */
    }
    
    .feed-list {
        padding-bottom: 8rem; /* Extra padding for mobile bottom bars */
    }

    .inspector-panel {
        position: fixed;
        top: 64px; /* Below header */
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 40; /* Below mobile menu (50) */
        border-radius: 0;
        border: none;
        margin: 0;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        width: 100%;
        height: calc(100dvh - 64px); /* Use dynamic viewport height */
        background-color: #fff;
    }

    .inspector-panel.open {
        transform: translateX(0);
    }

    .mobile-back-btn {
        display: flex !important;
        position: sticky;
        top: 0;
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(10px);
        z-index: 20;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }
    
    /* Perfect Circle Button Fix */
    #close-inspector {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem; /* 40px */
        height: 2.5rem; /* 40px */
        padding: 0;
        border-radius: 9999px;
        background-color: #F3F4F6;
        color: #4B5563;
        transition: background-color 0.2s;
    }
    
    #close-inspector:hover {
        background-color: #E5E7EB;
    }
    
    .inspector-content {
        padding: 1rem;
        padding-bottom: 8rem; /* Mobile bottom safe area */
    }
}
