/* MediVox Medical Dictation - Main Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Layout heights */
    --top-bar-height: 60px;
    --lower-bar-height: 175px; /* Increased to provide more spacing for audio controls */
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-width: 700px;
    overflow-x: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 700px;
}

/* Top Bar */
.top-bar {
    height: var(--top-bar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow);
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--primary-color);
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.action-btn:hover {
    background: var(--background);
    border-color: var(--primary-color);
}

.action-btn .btn-icon {
    font-size: 1rem;
}

/* Drag and drop styling for Import button */
.action-btn.drag-over {
    background: var(--accent-bg);
    border-color: var(--accent);
    border-width: 2px;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.action-btn.drag-over .btn-icon {
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-2px); }
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

.recordings-table-container {
    height: 100%;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow-y: auto;
    overflow-x: hidden;
}

.recordings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.recordings-table th,
.recordings-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.recordings-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.recordings-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.recordings-table th.sortable:hover {
    background: #e2e8f0;
}

.recordings-table th.sortable::after {
    content: '↕️';
    position: absolute;
    right: 8px;
    opacity: 0.5;
    font-size: 0.8rem;
}

.recordings-table th.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

.recordings-table th.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

.recordings-table tbody tr:hover {
    background: var(--background);
}

/* Selected recording highlighting - thicker left border */
.recordings-table tbody tr.selected {
    border-top: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    border-left: 9px solid var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

/* Remove Safari-specific rule since @supports was affecting Chrome too */

/* Audio level meter styling */
.recordings-table .exam-id {
    position: relative;
    z-index: 1;
}

.recordings-table .exam-id::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background: inherit;
    border-radius: 2px;
}


.no-recordings-row td {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px;
}

/* Lower Bar */
.lower-bar {
    height: var(--lower-bar-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 5px; /* Reduced padding for tighter layout */
}

.waveform-container {
    flex: 1;
    background: var(--background);
    margin: 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    min-height: 40px;
    max-height: 60px;
}

.waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

.controls-placeholder {
    height: 40px;
    background: var(--background);
    margin: 0 10px 10px 10px;
    border-radius: 4px;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
}

.controls-placeholder::before {
    content: 'Audio controls will appear here';
}

.network-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    overflow: hidden;
}

/* Network Quality Indicator */

.network-icon {
    font-size: 0.9rem;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.network-status {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    display: inline-block;
}

.network-quality-dots {
    display: flex;
    gap: 3px;
    overflow: hidden;
}

.network-quality-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s;
    flex-shrink: 0;
}

.network-quality-dots.excellent .dot {
    background: var(--success-color);
}

.network-quality-dots.good .dot:nth-child(-n+3) {
    background: var(--success-color);
}

.network-quality-dots.fair .dot:nth-child(-n+2) {
    background: var(--warning-color);
}

.network-quality-dots.poor .dot:nth-child(1) {
    background: var(--danger-color);
}

/* Status Indicators Container */
.status-indicators {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

/* Transcription Indicator */
.transcription-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.transcription-icon {
    font-size: 0.9rem;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.transcription-status {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.transcription-status.streaming {
    color: var(--accent);
}

.transcription-status.batch {
    color: var(--text-secondary);
}

.transcription-status.queued {
    color: var(--warning-color);
}

.transcription-status.complete {
    color: var(--success-color);
}

.transcription-status.failed {
    color: var(--danger-color);
}

.transcription-mode {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.transcription-mode.streaming {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.transcription-mode.batch {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

/* Enhanced transcription status indicator (clickable) */
.transcription-indicator {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.transcription-indicator:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.transcription-indicator.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Live Transcription Floating Panel */
.live-transcription-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    max-height: 500px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 900;
    display: flex;
    flex-direction: column;
    animation: panelSlideIn 0.3s ease-out;
    border: 1px solid var(--border);
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

.live-transcription-panel.minimized {
    max-height: 50px;
}

.live-transcription-panel.minimized .panel-body,
.live-transcription-panel.minimized .panel-footer {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to bottom, var(--surface), var(--background));
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
}

.panel-header:active {
    cursor: grabbing;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.panel-icon {
    font-size: 1.1rem;
}

.panel-title-text {
    color: var(--text-primary);
}

.panel-exam-id {
    padding: 2px 8px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.panel-controls {
    display: flex;
    gap: 4px;
}

.panel-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.panel-btn:hover {
    background: var(--background);
    color: var(--text-primary);
}

.close-btn:hover {
    background: var(--danger-color);
    color: white;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 200px;
    max-height: 380px;
}

.transcript-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.transcript-content p {
    margin: 0;
    padding: 0;
}

.waiting-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

.offline-message {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
}

.offline-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.offline-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.offline-description {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
    color: var(--text-secondary);
}

.streaming-status.offline {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

/* Live transcript word styling (same as transcription viewer) */
.transcript-content .word {
    display: inline;
    padding: 2px 0;
    transition: background-color 0.2s;
    border-radius: 3px;
}

.transcript-content .word.active {
    background: rgba(99, 102, 241, 0.2);
    font-weight: 600;
}

.transcript-content .word.confidence-high {
    /* No background - high confidence */
}

.transcript-content .word.confidence-good {
    background: rgba(156, 163, 175, 0.1);
}

.transcript-content .word.confidence-medium {
    background: rgba(251, 191, 36, 0.15);
}

.transcript-content .word.confidence-low {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
}

.transcript-content .word.partial {
    opacity: 0.5;
    font-style: italic;
    color: #6b7280;
}

.panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--background);
    border-radius: 0 0 12px 12px;
}

.transcript-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.stat-icon {
    font-size: 0.9rem;
}

.stat-separator {
    color: var(--border);
}

.streaming-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 600;
}

.streaming-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* Scrollbar styling for panel */
.panel-body::-webkit-scrollbar {
    width: 8px;
}

.panel-body::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.panel-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Global Drag and Drop Overlay */
.global-drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(37, 99, 235, 0.1);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.global-drag-overlay.show {
    opacity: 1;
}

.drag-overlay-content {
    background: var(--surface);
    border: 3px dashed var(--primary-color);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.2s ease-in-out;
}

.global-drag-overlay.show .drag-overlay-content {
    transform: scale(1);
}

.drag-overlay-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    animation: pulse 1.5s infinite;
}

.drag-overlay-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.drag-overlay-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.drag-overlay-types {
    display: flex;
    gap: 20px;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.drag-overlay-type {
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .action-buttons {
        flex-wrap: wrap;
    }
    
    .action-btn .btn-text {
        display: none;
    }
    
    .recordings-table {
        font-size: 0.8rem;
    }
    
    .recordings-table th,
    .recordings-table td {
        padding: 8px;
    }
    
    .drag-overlay-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .drag-overlay-types {
        flex-direction: column;
        gap: 12px;
    }
}