/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   APP CONTAINER
   ======================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    flex: 1;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

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

.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ========================================
   MAIN CONTENT — two-panel layout
   ======================================== */
.app-main {
    flex: 1;
    padding: 32px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ========================================
   TRANSCRIPTION CONTAINER
   ======================================== */
.transcription-container {
    flex: 1;
    min-width: 0;   /* prevents flex blowout */
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
}

/* ========================================
   SUMMARY PANEL
   ======================================== */
.summary-panel {
    width: 380px;
    flex-shrink: 0;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
    overflow: hidden;
}

.summary-panel--hidden {
    display: none;
}

/* Animation only fires when the panel becomes visible */
.summary-panel:not(.summary-panel--hidden) {
    animation: panelSlideIn 0.35s ease;
}

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

.summary-header {
    background: var(--bg-tertiary);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

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

.summary-title .icon {
    font-size: 1.4rem;
}

.summary-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    gap: 16px;
}

/* Prompt state */
.summary-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 20px;
    text-align: center;
}

.summary-prompt p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.summary-prompt--hidden,
.summary-loading--hidden,
.summary-result--hidden,
.summary-saved--hidden {
    display: none !important;
}

/* Loading state */
.summary-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    color: var(--text-secondary);
}

.summary-loading .spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
    color: var(--primary-color);
}

.summary-loading p {
    font-size: 0.9375rem;
}

/* Result state */
.summary-result {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 16px;
}

.summary-textarea {
    flex: 1;
    width: 100%;
    min-height: 180px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.summary-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Saved confirmation */
.summary-saved {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 16px;
    text-align: center;
}

.saved-icon {
    font-size: 3rem;
}

.summary-saved p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.transcription-header {
    background: var(--bg-tertiary);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

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

.transcription-title .icon {
    font-size: 1.5rem;
}

.transcription-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-indicator.status-ready {
    background: var(--text-muted);
}

.status-indicator.status-active {
    background: var(--success-color);
    animation: pulse-active 1.5s infinite;
}

.status-indicator.status-processing {
    background: var(--warning-color);
    animation: pulse 1s infinite;
}

.status-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-active {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* ========================================
   TRANSCRIPTION CONTENT
   ======================================== */
.transcription-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.transcription-content::-webkit-scrollbar {
    width: 8px;
}

.transcription-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.transcription-content::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

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

/* Placeholder */
.transcription-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.placeholder-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.transcription-placeholder p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Transcript Items */
.transcript-item {
    padding: 16px 20px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border-left: 4px solid var(--border-color);
    animation: slideUp 0.3s ease;
}

.transcript-item:hover {
    box-shadow: var(--shadow-sm);
}

.transcript-item.transcript-customer {
    border-left-color: var(--primary-color);
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.transcript-item.transcript-agent {
    border-left-color: var(--success-color);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.transcript-item.transcript-system {
    border-left-color: var(--text-muted);
    background: var(--bg-tertiary);
}

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

.transcript-speaker {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.transcript-text {
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.transcript-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ========================================
   FOOTER
   ======================================== */
.app-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, 0.05);
}

.footer-left {
    flex: 1;
}

.token-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.token-status.token-valid {
    color: var(--success-color);
}

.token-status.token-expired {
    color: var(--error-color);
}

.footer-right {
    display: flex;
    gap: 12px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

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

.btn-danger:hover {
    background: #dc2626;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    .app-header {
        padding: 12px 20px;
        flex-direction: column;
        gap: 12px;
    }

    .header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .app-main {
        padding: 16px;
        flex-direction: column;
    }

    .transcription-container,
    .summary-panel {
        width: 100%;
        height: auto;
        min-height: 300px;
        max-height: 50vh;
    }

    .app-footer {
        padding: 12px 20px;
        flex-direction: column;
        gap: 12px;
    }

    .footer-right {
        width: 100%;
        justify-content: center;
    }

    .btn {
        flex: 1;
        justify-content: center;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ========================================
   SPINNER
   ======================================== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}