:root {
    --brand-purple: #7B3FE4;
    --brand-dark: #1A1A2E;
    --brand-gradient: linear-gradient(135deg, #7B3FE4 0%, #A450FF 100%);
    --bg-dark: #0F0F1E;
    --card-bg: #1A1A2E;
    --text-main: #FFFFFF;
    --text-dim: #A0A0C0;
    --accent-green: #00FF9D;
    --accent-red: #FF4D4D;
    --glass-bg: rgba(26, 26, 46, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* Scrollbar Personalizada Premium */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(123, 63, 228, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(123, 63, 228, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.main-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.logo-area h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-area h1 span {
    color: var(--brand-purple);
}

.btn-history {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-history:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Recorder Wrapper */
.recorder-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 40px;
}

.status-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

.status-dot {
    width: 20px;
    height: 20px;
    background-color: var(--text-dim);
    border-radius: 50%;
    transition: all 0.5s ease;
}

.recording .status-dot {
    background-color: var(--accent-red);
    box-shadow: 0 0 20px var(--accent-red);
}

.pulse-ring {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent-red);
    border-radius: 50%;
    opacity: 0;
}

.recording .pulse-ring {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(4);
        opacity: 0;
    }
}

#app-status {
    font-size: 1.1rem;
    color: var(--text-dim);
    font-weight: 500;
}

.timer {
    font-size: 4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.input-group {
    width: 100%;
}

#meeting-title {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 18px;
    border-radius: 16px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

#meeting-title:focus {
    border-color: var(--brand-purple);
    background: rgba(255, 255, 255, 0.08);
}

/* Controls */
.controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.btn-record,
.btn-process {
    width: 100%;
    padding: 20px;
    border: none;
    border-radius: 100px;
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-record {
    background: var(--brand-gradient);
}

.btn-record.recording {
    background: var(--accent-red);
    transform: scale(0.98);
}

.btn-process {
    background: white;
    color: var(--brand-dark);
}

.btn-process:active {
    transform: scale(0.95);
}

/* TOC - Tabla de Contenidos Interactiva */
.toc-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--glass-border);
}

.toc-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 800;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-link {
    color: var(--brand-purple);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-link::before {
    content: '→';
    font-size: 0.8rem;
    opacity: 0.5;
}

.toc-link:hover {
    color: var(--text-main);
    transform: translateX(4px);
}

/* Results View */
#result-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    z-index: 1000;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    border-radius: 32px;
    padding: 32px;
    padding-right: 20px;
    /* Un poco menos a la derecha para el scroll */
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
}

.result-card::-webkit-scrollbar {
    width: 6px;
}

.result-card::-webkit-scrollbar-track {
    margin: 30px 0;
    /* Esto aleja el scroll de las esquinas redondeadas */
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: transparent;
    padding-bottom: 8px;
    z-index: 10;
}

.btn-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: rotate(90deg);
}

.result-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
}

#ai-content {
    line-height: 1.7;
    font-size: 1.05rem;
    color: var(--text-main);
}

#ai-content strong {
    color: var(--brand-purple);
}

/* Markdown Table Styling */
.ai-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: rgba(123, 63, 228, 0.1);
    text-align: left;
    padding: 12px;
    color: var(--brand-purple);
    font-weight: 800;
    border-bottom: 2px solid var(--glass-border);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}

tr:last-child td {
    border-bottom: none;
}

/* Headers in results */
#ai-content h2 {
    margin: 32px 0 16px 0;
    color: var(--brand-purple);
    font-size: 1.4rem;
    scroll-margin-top: 20px;
}

#ai-content h3 {
    margin: 24px 0 12px 0;
    color: white;
    font-size: 1.1rem;
    scroll-margin-top: 20px;
}

#ai-content ul,
#ai-content ol {
    padding-left: 20px;
    margin-bottom: 20px;
}

#ai-content li {
    margin-bottom: 8px;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-action {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Audio Player Stylized */
.audio-player-container {
    background: rgba(123, 63, 228, 0.1);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--glass-border);
}

audio {
    width: 100%;
    height: 40px;
}

/* Chrome/Safari Audio styling basics */
audio::-webkit-media-controls-enclosure {
    background-color: transparent;
}

/* Studio Integration Card */
.studio-promo-card {
    margin-top: 40px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(123, 63, 228, 0.2) 0%, rgba(164, 80, 255, 0.1) 100%);
    border: 1px solid var(--brand-purple);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: center;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.promo-text strong {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 4px;
    color: var(--accent-green) !important;
}

.promo-text p {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.btn-studio-link {
    background: var(--brand-gradient);
    color: white !important;
    text-decoration: none;
    padding: 16px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1rem;
    transition: transform 0.2s;
    box-shadow: 0 10px 20px rgba(123, 63, 228, 0.2);
}

.btn-studio-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(123, 63, 228, 0.3);
}

/* Sidebar */
#history-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--card-bg);
    z-index: 1100;
    padding: 24px;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.3);
}

#history-sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

/* History Items Styling */
.history-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--brand-purple);
    transform: translateY(-2px);
}

.history-item h3 {
    font-size: 1rem;
    margin-bottom: 4px;
    color: white;
}

.history-item .date {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.empty-msg {
    text-align: center;
    color: var(--text-dim);
    margin-top: 40px;
    font-style: italic;
}

.loader-small {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(123, 63, 228, 0.1);
    border-left-color: var(--brand-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.hidden {
    display: none !important;
}

/* Loader */
#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(123, 63, 228, 0.1);
    border-left-color: var(--brand-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}