/* ===================== CSS Variables ===================== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --success-bg: #d1fae5;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
}

/* ===================== Reset & Base ===================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ===================== Auth Pages (Login/Register) ===================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
    color: var(--white);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.auth-header p {
    color: var(--gray-500);
    font-size: 15px;
}

/* ===================== Alerts ===================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-error {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ===================== Forms ===================== */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label i {
    color: var(--gray-400);
    font-size: 12px;
}

.form-group input {
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 15px;
    font-family: inherit;
    color: var(--gray-800);
    transition: var(--transition);
    outline: none;
    background: var(--gray-50);
}

.form-group input:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

/* ===================== Buttons ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-start {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    padding: 12px 28px;
    font-size: 15px;
}

.btn-start:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    padding: 12px 28px;
    font-size: 15px;
}

.btn-stop:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-save {
    background: var(--primary);
    color: var(--white);
}

.btn-save:hover {
    background: var(--primary-dark);
}

.btn-clear {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-clear:hover {
    background: var(--gray-300);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.btn-icon:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.btn-icon-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ===================== Auth Footer ===================== */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.auth-footer p {
    color: var(--gray-500);
    font-size: 14px;
}

.auth-footer a {
    font-weight: 600;
}

/* ===================== Dashboard Layout ===================== */
.dashboard-page {
    display: flex;
    min-height: 100vh;
}

/* ===================== Sidebar ===================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--gray-400);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.2);
    color: var(--primary-light);
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: var(--radius);
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fecaca;
}

/* ===================== Main Content ===================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: 64px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    font-size: 18px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
    flex: 1;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 50px;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
}

.status-badge.listening {
    background: var(--success-bg);
    color: var(--success);
    animation: pulse 2s infinite;
}

.status-badge i {
    font-size: 8px;
}

/* ===================== Content Sections ===================== */
.content-section {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===================== Speech Controls ===================== */
.speech-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.controls-left, .controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.language-select {
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.language-select:focus {
    border-color: var(--primary);
}

/* ===================== Listening Indicator ===================== */
.listening-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(5, 150, 105, 0.08) 100%);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-lg);
    color: var(--success);
    font-weight: 600;
    font-size: 15px;
    position: relative;
}

.pulse-ring {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.3);
    animation: pulseRing 1.5s infinite;
    position: relative;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    position: absolute;
    left: 50%;
    margin-left: -18px;
    top: 50%;
    margin-top: -5px;
}

/* ===================== Document Title ===================== */
.doc-title-wrap {
    margin-bottom: 16px;
}

.doc-title-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 600;
    font-family: inherit;
    color: var(--gray-900);
    outline: none;
    transition: var(--transition);
    background: var(--white);
}

.doc-title-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ===================== Editor Wrapper ===================== */
.editor-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    min-height: 500px;
}

.editor-wrapper .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    padding: 10px 12px;
}

.editor-wrapper .ql-container {
    border: none;
    font-size: 16px;
    flex: 1;
}

.editor-wrapper .ql-editor {
    min-height: 400px;
    padding: 20px 24px;
    font-family: 'Inter', sans-serif;
    line-height: 1.8;
    color: var(--gray-800);
}

.editor-wrapper .ql-editor.ql-blank::before {
    color: var(--gray-400);
    font-style: normal;
}

/* ===================== Interim Text ===================== */
.interim-text {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius);
    color: #92400e;
    font-size: 14px;
    font-style: italic;
    display: none;
}

/* ===================== Documents Grid ===================== */
.documents-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.documents-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.doc-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 20px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.doc-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.doc-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.doc-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    flex: 1;
    word-break: break-word;
}

.doc-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.doc-card-preview {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.6;
    flex: 1;
    margin-bottom: 16px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.doc-card-footer {
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-400);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===================== Empty State ===================== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 56px;
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ===================== Toast Notifications ===================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--success);
    color: var(--white);
}

.toast-error {
    background: var(--danger);
    color: var(--white);
}

.toast-warning {
    background: var(--warning);
    color: var(--white);
}

.toast-info {
    background: var(--info);
    color: var(--white);
}

/* ===================== Animations ===================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.pulse-icon {
    animation: pulse 1s infinite;
}

/* ===================== Responsive ===================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .speech-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-left, .controls-right {
        justify-content: center;
    }

    .documents-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 28px 24px;
    }
}

@media (max-width: 480px) {
    .controls-left, .controls-right {
        flex-direction: column;
        width: 100%;
    }

    .controls-left .btn, .controls-right .btn,
    .controls-right .language-select {
        width: 100%;
    }

    .content-section {
        padding: 16px;
    }
}

/* ===================== Index Redirect ===================== */
/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Selection */
::selection {
    background: rgba(79, 70, 229, 0.2);
    color: var(--gray-900);
}
