/* ========================================
   Maestro - Application Styles
   ======================================== */

/* Base */
html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--mud-palette-background, #0D1117);
    color: var(--mud-palette-text-primary, #E6EDF3);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   App Bar & Navigation
   ======================================== */

.app-topbar {
    border-bottom: 1px solid var(--mud-palette-lines-default) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    /* Ensure the blurred app bar doesn't create a stacking context that
       fights with MudBlazor's drawer overlay on Safari/WebKit */
    z-index: var(--mud-zindex-appbar) !important;
}

.app-bottombar {
    border-top: 1px solid var(--mud-palette-lines-default) !important;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    min-width: 60px;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background-color 0.15s ease;
}

.bottom-nav-link:hover {
    background-color: var(--mud-palette-action-default-hover);
}

.bottom-nav-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--mud-palette-primary);
    margin-top: 2px;
}

/* ========================================
   Section Cards
   ======================================== */

.section-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    transition: border-color 0.2s ease;
}

.section-card:hover {
    border-color: var(--mud-palette-primary);
}

/* Action buttons in dashboard */
.action-button {
    border-radius: 10px !important;
    text-transform: none !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    padding: 10px 24px !important;
}

/* ========================================
   Login Page
   ======================================== */

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, rgba(139, 71, 229, 0.12) 0%, transparent 60%);
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.login-card {
    width: 100%;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px !important;
}

.login-button {
    border-radius: 10px !important;
    text-transform: none !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    height: 48px !important;
}

/* ========================================
   Timer Animation
   ======================================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.timer-active {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

.timer-expired {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
    animation: pulse 1s infinite;
}

/* ========================================
   Interview Page Layout
   ======================================== */

.interview-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 128px);
    height: calc(100dvh - 128px);
    overflow: hidden;
}

.interview-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding-top: 8px;
    padding-bottom: 8px;
}

.interview-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.interview-grid {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 24px;
}

.interview-chat-col {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.interview-sidebar {
    width: 300px;
    flex-shrink: 0;
}

@media screen and (max-width: 960px) {
    .interview-page {
        height: calc(100vh - 120px);
        height: calc(100dvh - 120px);
    }

    .interview-grid {
        flex-direction: column;
    }

    .interview-sidebar {
        width: 100%;
    }
}

/* ========================================
   Chat Panel & Bubbles
   ======================================== */

.chat-panel {
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--mud-palette-lines-default);
    height: calc(100vh - 220px);
    height: calc(100dvh - 220px);
    min-height: 300px;
}

/* When inside the interview page, fill parent */
.interview-chat-col .chat-panel {
    height: auto;
    flex: 1;
    min-height: 0;
}

.chat-bubble {
    word-break: break-word;
    transition: opacity 0.2s ease;
}

.chat-bubble-assistant {
    border-bottom-left-radius: 4px !important;
}

.chat-bubble-user {
    border-bottom-right-radius: 4px !important;
}

/* ========================================
   Leaderboard
   ======================================== */

.leaderboard-row {
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.leaderboard-row:hover {
    transform: translateX(4px);
}

/* ========================================
   Reaction Button
   ======================================== */

.reaction-button {
    transition: transform 0.15s ease;
}

.reaction-button:active {
    transform: scale(1.3);
}

/* ========================================
   Activity Feed
   ======================================== */

.activity-feed-enter {
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Scrollbar Styling
   ======================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #30363D;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484F58;
}

/* ========================================
   Markdown Content
   ======================================== */

.markdown-content {
    line-height: 1.7;
    font-size: 0.95rem;
}

.markdown-content h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.markdown-content h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    margin: 1.25rem 0 0.5rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.markdown-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    margin: 1rem 0 0.4rem;
}

.markdown-content h4, .markdown-content h5, .markdown-content h6 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    margin: 0.75rem 0 0.3rem;
}

.markdown-content p {
    margin: 0.5rem 0;
    color: var(--mud-palette-text-secondary);
}

.markdown-content ul, .markdown-content ol {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.markdown-content li {
    margin: 0.25rem 0;
    color: var(--mud-palette-text-secondary);
}

.markdown-content strong {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
}

.markdown-content em {
    color: var(--mud-palette-text-secondary);
    font-style: italic;
}

.markdown-content code {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    padding: 0.15rem 0.35rem;
    font-size: 0.85em;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    color: var(--mud-palette-info);
}

.markdown-content pre {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
}

.markdown-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.85rem;
    color: var(--mud-palette-text-primary);
}

.markdown-content blockquote {
    border-left: 3px solid var(--mud-palette-primary);
    margin: 0.75rem 0;
    padding: 0.5rem 1rem;
    background: rgba(139, 71, 229, 0.06);
    border-radius: 0 6px 6px 0;
    color: var(--mud-palette-text-secondary);
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.markdown-content thead th {
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 2px solid var(--mud-palette-lines-default);
}

.markdown-content tbody td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-secondary);
}

.markdown-content tbody tr:hover {
    background: rgba(139, 71, 229, 0.04);
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--mud-palette-lines-default);
    margin: 1rem 0;
}

.markdown-content a {
    color: var(--mud-palette-primary);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* ========================================
   Focus & Accessibility
   ======================================== */

*:focus-visible {
    outline: 2px solid #8b47e5;
    outline-offset: 2px;
}

/* ========================================
   Badges & Progress
   ======================================== */

.badge-chip {
    transition: transform 0.2s ease;
}

.badge-chip:hover {
    transform: scale(1.05);
}

.progress-step-active {
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.progress-step-inactive {
    color: var(--mud-palette-text-secondary);
}

/* ========================================
   Utilities
   ======================================== */

.w-100 {
    width: 100%;
}

/* Mic recording pulse animation */
@keyframes micPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(248, 81, 73, 0);
    }
}

.mic-pulse {
    animation: micPulse 1.5s infinite;
    border-radius: 50%;
}

/* ========================================
   Mobile Responsive Overrides
   ======================================== */

/* Prevent zoom on input focus for iOS */
@media screen and (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

/* Mobile-friendly touch targets */
@media (pointer: coarse) {
    .mud-icon-button {
        min-width: 44px;
        min-height: 44px;
    }

    .mud-button {
        min-height: 44px;
    }
}

/* Table horizontal scroll on mobile — only apply min-width via an opt-in class
   so simple tables (e.g. User Breakdown) aren't forced to scroll. */
@media screen and (max-width: 768px) {
    .mud-table-container,
    .mud-simple-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Markdown tables responsive */
@media screen and (max-width: 600px) {
    .markdown-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .markdown-content pre {
        max-width: calc(100vw - 3rem);
    }
}

/* Chat panel: fill available height on mobile */
@media screen and (max-width: 960px) {
    .chat-panel {
        height: calc(100vh - 280px);
        height: calc(100dvh - 280px);
        min-height: 260px;
    }

    /* Inside interview page, always flex-fill */
    .interview-chat-col .chat-panel {
        height: auto !important;
        flex: 1;
        min-height: 0;
    }

    .chat-bubble {
        max-width: 90% !important;
    }
}

/* Score submission: stack columns on small screens */
@media screen and (max-width: 960px) {
    .score-prd-viewer {
        max-height: 400px !important;
    }
}

/* Progress tracker: smaller text on mobile */
@media screen and (max-width: 600px) {
    .mud-typography-overline {
        font-size: 0.55rem !important;
        letter-spacing: 0.05em !important;
    }
}

/* Admin drawer overlay on mobile — drawer AND its backdrop must share the same z-index
   band, otherwise the overlay sits above content but below the drawer, blocking all taps
   after the drawer closes. The pointer-events rule ensures that if the overlay element
   lingers in the DOM after close (known MudBlazor behavior), it cannot intercept taps. */
@media screen and (max-width: 960px) {
    .mud-drawer {
        z-index: 1300 !important;
    }

    .mud-overlay.mud-overlay-drawer {
        z-index: 1299 !important;
    }

    .mud-drawer--closed + .mud-overlay,
    .mud-overlay.mud-overlay-drawer:not(.mud-overlay--visible) {
        pointer-events: none !important;
        opacity: 0 !important;
    }
}

/* Leaderboard: make table readable on small screens */
@media screen and (max-width: 600px) {
    .leaderboard-row td {
        padding: 0.4rem 0.3rem !important;
        font-size: 0.8rem;
    }
}

/* Page titles: slightly smaller on mobile */
@media screen and (max-width: 600px) {
    .mud-typography-h4 {
        font-size: 1.5rem !important;
    }

    .mud-typography-h5 {
        font-size: 1.15rem !important;
    }

    .mud-typography-h6 {
        font-size: 0.95rem !important;
    }
}

/* Login responsive */
@media screen and (max-width: 600px) {
    .login-card {
        border: none !important;
    }
}

/* Rating stars: ensure touch-friendly size on mobile */
@media (pointer: coarse) {
    .mud-rating .mud-icon-root {
        font-size: 2rem !important;
    }
}

/* Color picker: constrain width on mobile */
@media screen and (max-width: 600px) {
    .mud-picker-color {
        max-width: 100% !important;
    }
}

/* ========================================
   Blazor Loading
   ======================================== */

#blazor-error-ui {
    background: #F85149;
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
