/* ===== VARIÁVEIS E RESET ===== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* ===== BASE E TIPOGRAFIA ===== */
.onibus-linhares-container {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0;
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    font-weight: 400;
}

/* ===== HEADER MODERNO ===== */
.onibus-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.onibus-header::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.header-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.header-text h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.header-subtitle {
    margin: 0.25rem 0 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
    font-weight: 500;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.live-clock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.15);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

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

.clock-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.clock-text strong {
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.clock-text small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* ===== LEGENDA MINIMALISTA ===== */
.onibus-legend {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 0 1.5rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-color.accessible {
    background: var(--primary);
}

.legend-color.next {
    background: var(--warning);
}

/* ===== CONTEÚDO PRINCIPAL ===== */
.onibus-content {
    padding: 0 1.5rem 2rem;
}

/* ===== SEÇÃO DE GRUPO - RECOLHIDA INICIALMENTE ===== */
.grupo-section {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.grupo-section:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.grupo-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    position: relative;
}

.grupo-header:hover {
    background: #f1f5f9;
}

.grupo-badge {
    background: var(--primary);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    min-width: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.grupo-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.grupo-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: var(--radius);
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.grupo-toggle:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text);
}

.grupo-toggle svg {
    transition: transform 0.2s ease;
}

.grupo-toggle.active svg {
    transform: rotate(180deg);
}

/* CONTEÚDO DO GRUPO - ESCONDIDO INICIALMENTE */
.grupo-content {
    display: none;
    padding: 0;
    border-top: 1px solid var(--border);
}

.grupo-content.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

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

/* ===== LINHAS ATENDIDAS - RECOLHIDAS ===== */
.linhas-details {
    border-bottom: 1px solid var(--border);
}

.linhas-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    list-style: none;
}

.linhas-summary:hover {
    background: var(--surface);
}

.linhas-summary::-webkit-details-marker {
    display: none;
}

.summary-icon {
    font-size: 1.1rem;
    color: var(--text-light);
}

.summary-text {
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.summary-arrow {
    width: 16px;
    height: 16px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 6L8 10L4 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.linhas-details[open] .summary-arrow {
    transform: rotate(180deg);
}

.linhas-content {
    padding: 1rem 1.5rem 1.5rem;
    background: var(--surface);
}

.linhas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
}

.linha-card {
    background: var(--background);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition);
}

.linha-card:hover {
    border-color: var(--primary);
    background: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* ===== SEÇÃO DE DIAS - TODOS RECOLHIDOS ===== */
.day-section {
    border-bottom: 1px solid var(--border);
}

.day-section:last-child {
    border-bottom: none;
}

.day-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    list-style: none;
}

.day-summary:hover {
    background: var(--surface);
}

.day-summary::-webkit-details-marker {
    display: none;
}

.day-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.day-icon.sabado {
    color: var(--success);
}

.day-icon.domingo {
    color: var(--warning);
}

.day-title {
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.current-day-badge {
    background: var(--warning);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-arrow {
    width: 16px;
    height: 16px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 6L8 10L4 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.day-section[open] .day-arrow {
    transform: rotate(180deg);
}

.day-content {
    padding: 1rem 1.5rem;
    background: var(--surface);
}

/* ===== LOCAIS COMO ACCORDIONS RECOLHIDOS ===== */
.location-details {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--background);
}

.location-details:last-child {
    margin-bottom: 0;
}

.location-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    list-style: none;
    background: var(--surface);
}

.location-summary:hover {
    background: #f1f5f9;
}

.location-summary::-webkit-details-marker {
    display: none;
}

.location-icon {
    font-size: 1rem;
    color: var(--text-light);
    width: 16px;
    text-align: center;
}

.location-text {
    font-weight: 500;
    color: var(--text);
    flex: 1;
    font-size: 0.9rem;
}

.location-arrow {
    width: 14px;
    height: 14px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5 5.25L7 8.75L3.5 5.25' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color: var(--text-light);
    transition: transform 0.2s ease;
}

.location-details[open] .location-arrow {
    transform: rotate(180deg);
}

.location-content {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* ===== TABELAS DE HORÁRIOS ===== */
.schedule-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    box-shadow: var(--shadow);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 300px;
}

.schedule-table th {
    background: var(--surface);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.schedule-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.schedule-table tr:last-child td {
    border-bottom: none;
}

.schedule-table tr:hover {
    background: var(--surface);
}

.line-number {
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    width: 80px;
}

.schedule-time {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    width: 100px;
    position: relative;
}

.access-col {
    width: 60px;
    text-align: center;
}

.accessibility {
    text-align: center;
}

.access-icon {
    color: var(--primary);
    font-size: 1rem;
}

/* ===== PRÓXIMO HORÁRIO ===== */
.next-schedule {
    background: #fffbeb !important;
    border-left: 3px solid var(--warning);
    animation: pulse-gentle 2s ease-in-out infinite;
}

.next-schedule:hover {
    background: #fef3c7 !important;
}

.next-schedule .line-number {
    color: var(--warning);
    font-weight: 700;
}

.next-schedule .schedule-time {
    color: var(--warning);
    font-weight: 700;
}

.next-badge {
    background: var(--warning);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes pulse-gentle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

/* ===== HORÁRIOS PASSADOS ===== */
.past-schedule {
    opacity: 0.6;
}

.past-schedule .line-number,
.past-schedule .schedule-time {
    color: var(--text-lighter);
}

/* ===== ESTADO VAZIO ===== */
.onibus-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
    background: var(--surface);
    border-radius: var(--radius-lg);
    margin: 2rem;
}

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

.onibus-empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text);
    font-weight: 600;
}

.onibus-empty-state p {
    margin: 0;
    font-size: 0.9rem;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .onibus-header {
        padding: 1.25rem 1rem;
        border-radius: 0;
        margin-bottom: 1.25rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .header-icon {
        font-size: 1.75rem;
    }
    
    .header-text h1 {
        font-size: 1.35rem;
    }
    
    .header-meta {
        justify-content: center;
    }
    
    .onibus-content {
        padding: 0 1rem 1.5rem;
    }
    
    .onibus-legend {
        padding: 0 1rem;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .grupo-header {
        padding: 1rem;
    }
    
    .grupo-title {
        font-size: 1rem;
    }
    
    .linhas-content {
        padding: 0.75rem 1rem 1rem;
    }
    
    .linhas-grid {
        grid-template-columns: 1fr;
    }
    
    .day-summary {
        padding: 1rem;
    }
    
    .day-content {
        padding: 0.75rem 1rem;
    }
    
    .location-summary {
        padding: 0.75rem 1rem;
    }
    
    .location-content {
        padding: 0.75rem 1rem;
    }
    
    .schedule-table {
        font-size: 0.8rem;
        min-width: 280px;
    }
    
    .schedule-table th,
    .schedule-table td {
        padding: 0.5rem 0.75rem;
    }
    
    .line-number {
        width: 70px;
    }
    
    .schedule-time {
        width: 90px;
    }
}

@media (max-width: 480px) {
    .onibus-legend {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .header-meta {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .live-clock {
        width: 100%;
        justify-content: center;
    }
    
    .grupo-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .grupo-badge {
        min-width: 2rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .linha-card {
        padding: 0.6rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .next-badge {
        font-size: 0.65rem;
        padding: 0.15rem 0.4rem;
        margin-left: 0.25rem;
    }
    
    .location-text {
        font-size: 0.85rem;
    }
}

/* ===== ACESSIBILIDADE ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== FOCUS VISIBLE ===== */
.grupo-header:focus-visible,
.linhas-summary:focus-visible,
.day-summary:focus-visible,
.location-summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --text: #f1f5f9;
        --text-light: #cbd5e1;
        --text-lighter: #64748b;
    }
    
    .linha-card,
    .schedule-container,
    .location-details {
        background: var(--surface);
        border-color: var(--border);
    }
    
    .linha-card:hover {
        background: #1e293b;
    }
    
    .next-schedule {
        background: #451a03 !important;
    }
    
    .next-schedule:hover {
        background: #5a2305 !important;
    }
}

/* ===== ANIMAÇÕES DE ENTRADA ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grupo-section {
    animation: fadeInUp 0.4s ease-out;
}

.grupo-section:nth-child(1) { animation-delay: 0.1s; }
.grupo-section:nth-child(2) { animation-delay: 0.2s; }
.grupo-section:nth-child(3) { animation-delay: 0.3s; }

/* ===== UTILITÁRIOS ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}