/**
 * ATIVIDADE PARLAMENTAR - APPLE MATERIAL DESIGN
 * Versão: 1.0.1 (versao02)
 * Autor: GovTech By Siqueira&Souza Company
 */

/* ==========================================================================
   1. Variáveis e Reset de Escopo Apple Design
   ========================================================================== */
.apple-ap-portal,
.ap-portal-wrapper {
    --apple-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --apple-bg-base: #fbfbfd;
    --apple-card-bg: #ffffff;
    --apple-card-border: rgba(0, 0, 0, 0.08);
    --apple-card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
    --apple-card-shadow-hover: 0 16px 36px -4px rgba(0, 0, 0, 0.10), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
    --apple-radius-sm: 8px;
    --apple-radius-md: 14px;
    --apple-radius-lg: 18px;
    --apple-radius-pill: 9999px;
    --apple-text-title: #1d1d1f;
    --apple-text-body: #334155;
    --apple-text-muted: #64748b;
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;
    --apple-blue-soft: #f0f7ff;
    --apple-teal: #0284c7;
    --apple-teal-soft: #e0f2fe;
    --apple-green: #10b981;
    --apple-green-soft: #ecfdf5;
    --apple-orange: #f59e0b;
    --apple-orange-soft: #fffbeb;
    --apple-purple: #8b5cf6;
    --apple-purple-soft: #f5f3ff;
    --apple-transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);

    font-family: var(--apple-font);
    color: var(--apple-text-body);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 0 60px 0;
    box-sizing: border-box;
}

.apple-ap-portal *,
.apple-ap-portal *::before,
.apple-ap-portal *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   2. Painel de Controle e Métricas Rápidas Apple
   ========================================================================== */
.ap-hero-header {
    background: linear-gradient(135deg, #0a2540 0%, #173860 50%, #205493 100%);
    border-radius: var(--apple-radius-lg);
    padding: 32px 30px;
    color: #ffffff;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(10, 37, 64, 0.15);
    position: relative;
    overflow: hidden;
}

.ap-hero-header::after {
    content: '';
    position: absolute;
    right: -40px;
    bottom: -40px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.ap-hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 5px 14px;
    border-radius: var(--apple-radius-pill);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.ap-hero-title {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 10px 0;
    letter-spacing: -0.4px;
    line-height: 1.25;
    color: #ffffff;
}

.ap-hero-subtitle {
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.88);
    max-width: 800px;
    margin: 0 0 24px 0;
}

/* Grid de Métricas */
.ap-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.ap-metric-card {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--apple-radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: var(--apple-transition);
}

.ap-metric-card:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
}

.ap-metric-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #ffffff;
    flex-shrink: 0;
}

.icon-blue  { background: rgba(0, 113, 227, 0.45); }
.icon-teal  { background: rgba(2, 132, 199, 0.45); }
.icon-amber { background: rgba(245, 158, 11, 0.45); }
.icon-green { background: rgba(16, 185, 129, 0.45); }

.ap-metric-number {
    display: block;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    color: #ffffff;
}

.ap-metric-label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   3. Abas Segmented Control (Padrão iOS / macOS)
   ========================================================================== */
.ap-nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 22px;
    padding: 6px;
    background: #f1f5f9;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.ap-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: var(--apple-transition);
}

.ap-tab-btn:hover {
    color: var(--apple-blue);
    background: rgba(255, 255, 255, 0.7);
}

.ap-tab-btn.active {
    background: #ffffff;
    color: #0a2540;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   4. Barra de Busca e Filtros Inteligentes
   ========================================================================== */
.ap-filter-bar {
    background: #ffffff;
    border: 1px solid var(--apple-card-border);
    border-radius: var(--apple-radius-lg);
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: var(--apple-card-shadow);
}

.ap-filter-search-group {
    position: relative;
    margin-bottom: 16px;
}

.ap-filter-search-group i.fa-magnifying-glass {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 16px;
}

.ap-filter-search-group input {
    width: 100%;
    height: 46px;
    padding: 10px 42px 10px 46px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--apple-radius-pill);
    font-size: 14.5px;
    color: #1e293b;
    transition: var(--apple-transition);
}

.ap-filter-search-group input:focus {
    background: #ffffff;
    border-color: var(--apple-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

#ap-search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 20px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
}

.ap-filter-selects-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)) auto;
    gap: 12px;
    align-items: flex-end;
}

.ap-select-box {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ap-select-box label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ap-select-box select {
    height: 40px;
    padding: 6px 14px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--apple-radius-md);
    font-size: 13.5px;
    color: #1e293b;
    cursor: pointer;
    transition: var(--apple-transition);
    width: 100%;
}

.ap-select-box select:focus {
    border-color: var(--apple-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.ap-btn-reset {
    height: 40px;
    padding: 0 16px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: var(--apple-radius-md);
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--apple-transition);
    white-space: nowrap;
}

.ap-btn-reset:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* ==========================================================================
   5. Lista de Matérias e Cards Apple Material
   ========================================================================== */
.ap-results-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--apple-card-border);
}

.ap-results-count {
    font-size: 13.5px;
    color: var(--apple-text-muted);
}

.ap-results-count strong {
    color: #0a2540;
    font-weight: 700;
}

.ap-view-toggle {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
}

.ap-btn-view-mode {
    background: transparent;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #64748b;
    font-size: 13px;
    transition: var(--apple-transition);
}

.ap-btn-view-mode.active {
    background: #ffffff;
    color: #0a2540;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Grid de Cards */
.ap-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

/* Card Apple Puro */
.ap-card-apple {
    background: #ffffff;
    border: 1px solid var(--apple-card-border);
    border-radius: var(--apple-radius-lg);
    padding: 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--apple-card-shadow);
    transition: var(--apple-transition);
    position: relative;
}

.ap-card-apple:hover {
    transform: translateY(-3px);
    box-shadow: var(--apple-card-shadow-hover);
    border-color: rgba(0, 0, 0, 0.12);
}

.ap-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}

/* Badges Soft Apple */
.ap-badge-tipo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--apple-radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--apple-blue-soft);
    color: var(--apple-blue);
}

.ap-badge-tipo.tipo-atas-das-reunioes { background: #e0f2fe; color: #0284c7; }
.ap-badge-tipo.tipo-pautas-das-reunioes { background: #ccfbf1; color: #0f766e; }
.ap-badge-tipo.tipo-projetos-de-lei { background: #fef3c7; color: #b45309; }
.ap-badge-tipo.tipo-leis-municipais { background: #dcfce7; color: #15803d; }
.ap-badge-tipo.tipo-decretos-legislativos { background: #fae8ff; color: #86198f; }
.ap-badge-tipo.tipo-portarias { background: #f1f5f9; color: #334155; }
.ap-badge-tipo.tipo-requerimentos { background: #ffedd5; color: #c2410c; }
.ap-badge-tipo.tipo-indicacoes { background: #e0e7ff; color: #3730a3; }
.ap-badge-tipo.tipo-mocoes { background: #fce7f3; color: #9d174d; }

.ap-badge-status {
    padding: 3px 10px;
    border-radius: var(--apple-radius-pill);
    font-size: 11px;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
}

.ap-badge-status.status-aprovado,
.ap-badge-status.status-vigente { background: #dcfce7; color: #15803d; }
.ap-badge-status.status-em-tramitacao { background: #fef9c3; color: #a16207; }
.ap-badge-status.status-promulgado { background: #dbeafe; color: #1d4ed8; }
.ap-badge-status.status-rejeitado { background: #fee2e2; color: #b91c1c; }

.ap-card-id-row {
    margin-bottom: 8px;
}

.ap-card-num-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 5px 0;
}

.ap-card-num-title a {
    color: var(--apple-text-title);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ap-card-num-title a:hover {
    color: var(--apple-blue);
}

.ap-card-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.ap-card-sessao-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--apple-teal);
    background: var(--apple-teal-soft);
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.ap-card-ementa {
    font-size: 13.5px;
    line-height: 1.6;
    color: #475569;
    margin-bottom: 18px;
    flex-grow: 1;
}

.ap-card-ementa p {
    margin: 0;
}

/* Rodapé do Card */
.ap-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--apple-card-border);
    gap: 10px;
}

.ap-card-author-block {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: 60%;
}

.ap-card-author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--apple-blue);
    flex-shrink: 0;
}

.ap-card-author-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #0a2540;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.ap-card-author-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ap-author-label-small {
    font-size: 10.5px;
    color: #94a3b8;
    line-height: 1.2;
}

.ap-author-name {
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-author-name:hover {
    color: var(--apple-blue);
}

.ap-author-partido {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

/* Botões de Ação Apple */
.ap-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.ap-btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 12px;
    border-radius: var(--apple-radius-pill);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--apple-transition);
}

.ap-btn-download {
    background: #0a2540;
    color: #ffffff;
    gap: 6px;
}

.ap-btn-download:hover {
    background: var(--apple-blue);
    color: #ffffff;
    transform: scale(1.02);
}

.ap-btn-view-modal {
    background: #f1f5f9;
    color: #334155;
    width: 34px;
    padding: 0;
}

.ap-btn-view-modal:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.ap-btn-video {
    background: #fee2e2;
    color: #b91c1c;
    width: 34px;
    padding: 0;
}

.ap-btn-video:hover {
    background: #fecaca;
}

.ap-btn-details {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
    width: 34px;
    padding: 0;
}

.ap-btn-details:hover {
    background: #0a2540;
    color: #ffffff;
    border-color: #0a2540;
}

/* Modo Lista */
.ap-items-grid.is-list-view {
    grid-template-columns: 1fr;
}

.ap-items-grid.is-list-view .ap-card-apple {
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
}

.ap-items-grid.is-list-view .ap-card-header {
    margin-bottom: 0;
    flex-direction: column;
    align-items: flex-start;
    width: 140px;
    flex-shrink: 0;
}

.ap-items-grid.is-list-view .ap-card-id-row {
    margin-bottom: 0;
    width: 250px;
    flex-shrink: 0;
    padding: 0 15px;
}

.ap-items-grid.is-list-view .ap-card-ementa {
    margin-bottom: 0;
    padding: 0 15px;
}

.ap-items-grid.is-list-view .ap-card-footer {
    border-top: none;
    padding-top: 0;
    width: auto;
    flex-shrink: 0;
}

/* ==========================================================================
   6. Modal de Pré-visualização de Documento
   ========================================================================== */
.ap-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.ap-modal-window {
    background: #ffffff;
    width: 900px;
    max-width: 95vw;
    height: 85vh;
    border-radius: var(--apple-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: apModalFadeIn 0.25s ease-out;
}

@keyframes apModalFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.ap-modal-header {
    padding: 16px 22px;
    background: #f8fafc;
    border-bottom: 1px solid var(--apple-card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ap-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    max-width: 65%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ap-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ap-modal-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--apple-blue);
    color: #ffffff;
    border-radius: var(--apple-radius-pill);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease;
}

.ap-modal-btn-download:hover {
    background: var(--apple-blue-hover);
    color: #ffffff;
}

.ap-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.ap-modal-close:hover {
    color: #0f172a;
}

.ap-modal-body {
    flex-grow: 1;
    position: relative;
    background: #525659;
}

.ap-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   7. Loader e Estados Vazios
   ========================================================================== */
.ap-empty-state {
    text-align: center;
    padding: 45px 20px;
    background: #ffffff;
    border: 1px dashed #cbd5e1;
    border-radius: var(--apple-radius-lg);
    grid-column: 1 / -1;
}

.ap-empty-icon {
    font-size: 40px;
    color: #94a3b8;
    margin-bottom: 10px;
}

.ap-empty-state h3 {
    margin: 0 0 6px 0;
    font-size: 17px;
    font-weight: 700;
    color: #334155;
}

.ap-empty-state p {
    margin: 0;
    color: #64748b;
    font-size: 13.5px;
}

.ap-ajax-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 35px;
    grid-column: 1 / -1;
    color: var(--apple-blue);
    font-weight: 600;
    font-size: 14px;
}

.ap-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--apple-blue);
    border-radius: 50%;
    animation: apSpin 0.8s linear infinite;
}

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

/* ==========================================================================
   8. Responsividade (Mobile e Tablets)
   ========================================================================== */
@media (max-width: 991px) {
    .ap-hero-title { font-size: 24px; }
    .ap-items-grid { grid-template-columns: 1fr; }
    .ap-filter-selects-row { grid-template-columns: 1fr; }
    .ap-items-grid.is-list-view .ap-card-apple { flex-direction: column; align-items: stretch; }
    .ap-items-grid.is-list-view .ap-card-header,
    .ap-items-grid.is-list-view .ap-card-id-row,
    .ap-items-grid.is-list-view .ap-card-ementa { width: 100%; padding: 0; margin-bottom: 10px; }
}

@media (max-width: 600px) {
    .ap-hero-header { padding: 22px 18px; border-radius: var(--apple-radius-md); }
    .ap-hero-title { font-size: 21px; }
    .ap-nav-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 8px; }
    .ap-tab-btn { white-space: nowrap; }
    .ap-card-footer { flex-direction: column; align-items: flex-start; gap: 12px; }
    .ap-card-author-block { max-width: 100%; }
    .ap-card-actions { width: 100%; justify-content: flex-end; }
}
