@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables */
:root {
    --sidebar-width: 320px;
    --primary-color: #2DD4BF;
    --primary-hover: #14B8A6;
    --bg-dark: #0A0A0A;
    --bg-sidebar: #161616;
    --bg-section: #111111;
    --bg-elevated: #1A1A1A;
    --text-primary: #EDEDED;
    --text-secondary: #888888;
    --text-muted: #555555;
    --border-color: #1F1F1F;
    --border-light: #333333;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #FBBF24;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

/* Home Button */
.home-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.2s;
}

.home-button:hover {
    color: white;
    background: rgba(0, 0, 0, 0.3);
    transform: translateX(-2px);
}

.home-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: contain;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sidebar-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section h2 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* User Account Section */
.user-account {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.auth-view.hidden {
    display: none;
}

.btn-login {
    display: inline-block;
    padding: 10px 20px;
    background: var(--primary-color);
    color: #0A0A0A;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.user-email {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.credit-balance {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: rgba(45, 212, 191, 0.15);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
}

.user-actions {
    display: flex;
    gap: 8px;
}

.btn-buy-credits {
    flex: 1;
    padding: 8px 12px;
    background: rgba(72, 187, 120, 0.9);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-buy-credits:hover {
    background: rgba(72, 187, 120, 1);
}

.btn-logout {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Credit Cost Info */
.credit-cost-info {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* How It Works */
.how-it-works {
    list-style: none;
    padding: 0;
}

.how-it-works li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.how-it-works li:last-child {
    margin-bottom: 0;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    min-width: 22px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* Input Section */
.input-section {
    padding: 32px;
    border-bottom: 1px solid var(--border-color);
}

.input-wrapper {
    max-width: 700px;
    margin: 0 auto;
}

.input-wrapper h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.input-wrapper p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.url-input-group {
    display: flex;
    gap: 10px;
}

.url-input {
    flex: 1;
    padding: 14px 16px;
    background-color: var(--bg-section);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(252, 76, 2, 0.15);
}

.url-input::placeholder {
    color: var(--text-secondary);
}

.url-helper {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-pull-url {
    font-size: 13px;
    color: var(--primary-color);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-pull-url:hover {
    background: rgba(252, 76, 2, 0.08);
    border-color: var(--primary-color);
}

.btn-transcribe {
    padding: 14px 28px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    white-space: nowrap;
}

.btn-transcribe:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(252, 76, 2, 0.3);
}

.btn-transcribe:active:not(:disabled) {
    transform: translateY(0);
}

.btn-transcribe:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Upload Section */
.upload-section {
    margin: 0 32px 24px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.upload-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    width: 100%;
}

.upload-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.upload-zone {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.upload-zone.upload-zone--expanded {
    max-height: 420px;
    overflow: visible;
}

.upload-zone.drag-over {
    background: rgba(252, 76, 2, 0.08);
    border-color: var(--primary-color);
}

.upload-zone-inner {
    padding: 20px;
}

.upload-formats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 12px;
}

.upload-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.btn-upload-source {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-upload-source:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--text-secondary);
}

.upload-drag-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 12px;
}

.upload-file-list {
    min-height: 40px;
    margin-bottom: 12px;
}

.upload-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-section);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.upload-file-item .upload-file-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.upload-file-item .upload-file-remove:hover {
    color: var(--primary-color);
}

.upload-credit-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.upload-transcribe-btn {
    width: 100%;
}

.transcript-cards {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 700px;
    margin: 0 auto 24px;
}

.transcript-cards.hidden {
    display: none;
}

.transcript-card {
    background: var(--bg-section);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.transcript-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.transcript-card-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.transcript-card-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.transcript-card-body {
    padding: 16px;
}

.transcript-card .transcript-controls {
    margin-bottom: 12px;
}

.transcript-card .transcript-display {
    max-height: 280px;
}

.transcript-card-error {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Transcript Result Section */
.transcript-section {
    flex: 1;
    padding: 0 32px 32px;
    display: none;
}

.transcript-section.visible {
    display: block;
}

.transcript-container {
    max-width: 700px;
    margin: 0 auto;
}

/* Video Info */
.video-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.segment-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Transcript Controls */
.transcript-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

/* Tab Toggle */
.tab-toggle {
    display: flex;
    background: var(--bg-section);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

/* Transcript actions (Copy + Download) */
.transcript-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Copy Button */
.btn-copy,
.btn-download {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover,
.btn-download:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-secondary);
}

.btn-copy.copied {
    background: rgba(72, 187, 120, 0.2);
    border-color: var(--success-color);
    color: var(--success-color);
}

/* Transcript Display */
.transcript-display {
    background: var(--bg-section);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    padding: 20px;
}

.transcript-line {
    display: flex;
    gap: 14px;
    padding: 6px 0;
    line-height: 1.6;
    font-size: 0.9rem;
}

.transcript-line + .transcript-line {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.timestamp {
    flex-shrink: 0;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--primary-color);
    padding-top: 2px;
    min-width: 70px;
    cursor: pointer;
    transition: color 0.15s;
}

.timestamp:hover {
    color: var(--primary-color);
}

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

/* Plain text mode */
.transcript-display.plain-mode .timestamp {
    display: none;
}

.transcript-display.plain-mode .transcript-line {
    border-top: none;
    padding: 2px 0;
}

/* Empty / Error States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 32px;
    text-align: center;
    flex: 1;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Loading State */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(26, 26, 46, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#loading-text {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Status Message */
.status-message {
    padding: 12px 20px;
    font-size: 0.8rem;
    text-align: center;
}

.status-message.hidden {
    display: none;
}

.status-message.success {
    background-color: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.status-message.error {
    background-color: rgba(252, 129, 129, 0.1);
    color: var(--error-color);
}

.status-message.warning {
    background-color: rgba(246, 173, 85, 0.1);
    color: var(--warning-color);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-container {
    background: var(--bg-sidebar);
    border-radius: 12px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.2s ease-out;
    border: 1px solid var(--border-color);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    justify-content: flex-end;
}

/* Extension Install Banner */
.extension-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 24px 0;
    padding: 12px 16px;
    background: rgba(252, 76, 2, 0.1);
    border: 1px solid rgba(252, 76, 2, 0.3);
    border-radius: 8px;
}

.extension-banner.hidden {
    display: none;
}

.extension-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.extension-banner-content svg {
    flex-shrink: 0;
    color: var(--primary-color);
}

.extension-banner-content p {
    margin: 0;
}

.extension-banner-dismiss {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

.extension-banner-dismiss:hover {
    color: var(--text-primary);
}

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
        min-width: 280px;
    }

    .sidebar-section {
        padding: 14px 16px;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: none;
        height: auto;
        border-right: none;
        border-bottom: none;
        overflow-y: visible;
        flex-shrink: 0;
    }

    .sidebar-header {
        padding: 16px;
        position: relative;
    }

    .sidebar-header h1 {
        font-size: 1.1rem;
    }

    .sidebar-section {
        padding: 12px 16px;
    }

    .main-content {
        min-height: 70vh;
        overflow-y: visible;
    }

    .input-section {
        padding: 20px 16px;
    }

    .url-input-group {
        flex-direction: column;
    }

    .btn-transcribe {
        width: 100%;
    }

    .transcript-section {
        padding: 0 16px 24px;
    }

    .transcript-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .transcript-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .tab-toggle {
        justify-content: center;
    }

    .btn-copy,
    .btn-download {
        justify-content: center;
    }

    .transcript-display {
        max-height: none;
    }

    .empty-state {
        padding: 40px 16px;
    }

    .user-account {
        margin-top: 12px;
        padding-top: 12px;
    }

    .user-info {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .user-email {
        max-width: 120px;
    }

    .modal-container {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
}

/* Responsive Design - Small Phone */
@media (max-width: 480px) {
    .sidebar-header h1 {
        font-size: 1rem;
    }

    .sidebar-header .subtitle {
        font-size: 0.7rem;
    }

    .user-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn-buy-credits,
    .btn-logout {
        width: 100%;
    }

    .video-title {
        font-size: 0.95rem;
    }
}
