/* ============================================
   Design System v2.0 — CSS Variables
   ============================================ */
:root {
  /* ========== CORES ========== */
  /* Primária: vinho (identidade GCE Advocacia) */
  --color-primary-900: #4A0F1C;
  --color-primary-700: #6B1229;
  --color-primary-500: #8B1538;
  --color-primary-300: #A82649;
  --color-primary-100: #D4A5B4;

  /* Destaque: azul APENAS para links e badges neutros */
  --color-accent: #007BFF;
  --color-accent-hover: #0056b3;

  /* Neutros */
  --color-bg: #f4f7f9;
  --color-surface: #ffffff;
  --color-surface-elevated: #fafbfc;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-strong: rgba(0, 0, 0, 0.12);
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #555555;
  --color-text-muted: #888888;

  /* Semânticos */
  --color-success-bg: #e8f5e9;
  --color-success-text: #2e7d32;
  --color-success-border: #a5d6a7;
  --color-error-bg: #ffebee;
  --color-error-text: #c62828;
  --color-error-border: #c62828;
  --color-warning-bg: #fff8e1;
  --color-warning-text: #f57c00;
  --color-warning-border: #ffcc80;

  /* Categorias */
  --color-correspondent: #8e44ad;
  --color-correspondent-light: #f4ecf7;
  --color-normal: #2ecc71;
  --color-normal-light: #e8f8f0;

  /* ========== TIPOGRAFIA ========== */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.5rem;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;

  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* ========== ESPAÇAMENTOS ========== */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  /* ========== RADIUS ========== */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* ========== SOMBRAS ========== */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-focus: 0 0 0 3px rgba(139, 21, 56, 0.15);

  /* ========== TRANSIÇÕES ========== */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
}

/* --- Geral --- */
body {
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text-primary);
    padding: var(--space-5) var(--space-2);
}

.container {
    background: var(--color-surface);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 95%;
    max-width: 1200px;
    animation: fadeIn 0.8s ease-in-out;
}

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

/* --- Cabeçalho --- */
h1 {
    color: var(--color-text-primary);
    margin-bottom: var(--space-1);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-extrabold);
}

p {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Botão Principal --- */
button, .btn-main {
    background: linear-gradient(135deg, var(--color-primary-500) 0%, var(--color-primary-700) 100%);
    color: white;
    padding: 16px 40px;
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(139, 21, 56, 0.3);
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover, .btn-main:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(139, 21, 56, 0.4); /* var(--color-primary-500) com 40% opacity */
}

button:disabled, .btn-main:disabled {
    background: var(--color-text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* --- Loader do Botão --- */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-surface);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
    margin-right: var(--space-1);
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

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

.loading-overlay .loading-text {
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
    text-align: center;
}

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

/* --- Kstats Cards --- */
.kstats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.kstat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.kstat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kstat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-extrabold);
    color: var(--color-primary-500);
    line-height: var(--line-height-tight);
}

.kstat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    font-weight: var(--font-weight-medium);
}

/* --- Empty Day Column --- */
.empty-day-column {
    background: var(--color-surface-elevated);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

/* --- Container do Relatório --- */
#reportContainer {
    margin-top: var(--space-5);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-4);
    text-align: left;
}

/* --- Mensagens de Status --- */
.error-message, .no-conflict-message, .no-hearings-message {
    text-align: center;
    padding: var(--space-5);
    border-radius: var(--radius-md);
    margin: var(--space-2) 0;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-medium);
}

.error-message {
    background-color: var(--color-error-bg);
    color: var(--color-error-text);
    border: 1px solid var(--color-error-text);
}

.no-conflict-message, .no-hearings-message {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-text);
}

/* --- Seções --- */
.conflicts-section, .hearings-section {
    margin-bottom: var(--space-5);
}

h2 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-3);
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-border-strong);
    padding-bottom: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h2 .subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-weight: var(--font-weight-normal);
}

.conflict-header {
    color: var(--color-error-text);
    border-bottom-color: var(--color-error-text);
}

/* --- Card de Conflito --- */
.conflict-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition-normal);
}

.conflict-card:hover {
    box-shadow: var(--shadow-lg);
}

/* --- Tabela de Conflitos --- */
.conflict-table {
    width: 100%;
    border-collapse: collapse;
}

.conflict-table th, .conflict-table td {
    padding: var(--space-3);
    text-align: left;
    vertical-align: top;
}

.conflict-table th {
    background-color: var(--color-surface-elevated);
    color: var(--color-text-primary);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-lg);
}

.conflict-table td {
    border-top: 1px solid var(--color-border);
}

.conflict-table tr td:first-child {
    border-right: 1px solid var(--color-border);
}

/* --- Detalhes da Audiência --- */
.hearing-details p {
    margin: 0 0 var(--space-1) 0;
    font-size: var(--font-size-base);
    color: var(--color-text-secondary);
    line-height: var(--line-height-normal);
}

.hearing-details .task strong,
.hearing-details .process strong {
    color: var(--color-text-primary);
}

.hearing-details .time {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary-500);
}

.conflict-table .time {
    color: var(--color-error-text);
}

/* --- Lista de Todas as Audiências --- */
.hearings-list {
    list-style-type: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-2);
}

.hearings-list li {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: transform var(--transition-fast), box-shadow var(--transition-normal);
}

.hearings-list li:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.hearings-list .date {
    font-weight: var(--font-weight-semibold);
    color: var(--color-success-text);
}

/* --- Abas --- */
.tabs-container {
    margin-top: var(--space-4);
    border-bottom: 2px solid var(--color-border);
}

.tabs {
    display: flex;
    gap: var(--space-1);
    margin-bottom: -2px;
}

.tab-btn {
    background: none;
    border: none;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-normal);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    box-shadow: none;
}

.tab-btn:hover {
    color: var(--color-primary-500);
    background-color: var(--color-surface-elevated);
    transform: none;
}

.tab-btn.active {
    color: var(--color-primary-500);
    border-bottom-color: var(--color-primary-500);
    background-color: var(--color-surface-elevated);
}

.tab-content {
    display: none;
    padding-top: var(--space-4);
    animation: fadeIn 0.5s ease-in-out;
}

.tab-content.active {
    display: block;
}

/* --- Categorias de Audiência --- */
.category-section {
    margin-bottom: var(--space-6);
}

.category-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-border-strong);
}

.category-title h2 {
    margin-bottom: 0;
    border-bottom: none;
}

.badge-count {
    background: var(--color-accent);
    color: var(--color-surface);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
}

.correspondent-section .category-title h2 {
    color: var(--color-correspondent);
}

.correspondent-section .badge-count {
    background: var(--color-correspondent);
}

/* --- Cards de Audiência --- */
.hearing-card {
    display: flex;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: all var(--transition-normal);
    margin-bottom: var(--space-2);
}

.hearing-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary-300);
}

.hearing-card.is-correspondent {
    border-left: 5px solid var(--color-correspondent);
}

.hearing-card.normal {
    border-left: 5px solid var(--color-normal);
}

.hearing-date-badge {
    background: var(--color-surface-elevated);
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    border-right: 1px solid var(--color-border);
}

.hearing-card.is-correspondent .hearing-date-badge {
    background: var(--color-correspondent-light);
}

.day-week {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.day-number {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-extrabold);
    color: var(--color-text-primary);
    line-height: 1;
    margin: var(--space-1) 0;
}

.month {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary-500);
}

.hearing-info {
    padding: var(--space-3);
    flex-grow: 1;
}

.hearing-task {
    margin: 0 0 var(--space-1) 0;
    font-size: var(--font-size-lg);
    color: var(--color-text-primary);
}

.hearing-process, .hearing-time, .hearing-responsible {
    margin: var(--space-1) 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.hearing-time {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

/* --- Aba Semanal --- */
.weekly-view-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    background: var(--color-surface-elevated);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.filter-group label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-secondary);
}

.filter-group select, .filter-group input {
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.weekly-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-2);
}

.day-column {
    background: var(--color-surface-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    padding: var(--space-2);
}

.day-column-header {
    padding-bottom: var(--space-1);
    margin-bottom: var(--space-2);
    border-bottom: 2px solid var(--color-border-strong);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-column-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--color-text-primary);
}

.day-count {
    background: var(--color-border);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
}

/* --- Cards de Usuário --- */
.user-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition-normal);
}

.user-card:hover {
    box-shadow: var(--shadow-lg);
}

.user-header {
    background: linear-gradient(135deg, var(--color-surface-elevated) 0%, var(--color-border) 100%);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-normal);
}

.user-header:hover {
    background: linear-gradient(135deg, var(--color-border) 0%, var(--color-bg) 100%);
}

.user-header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-icon {
    margin-right: var(--space-1);
    font-size: var(--font-size-lg);
}

.user-name {
    flex: 1;
    font-weight: var(--font-weight-semibold);
}

.user-count {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-normal);
    margin-left: var(--space-1);
}

.toggle-icon {
    color: var(--color-primary-500);
    transition: transform var(--transition-normal);
    font-size: var(--font-size-sm);
}

/* --- Conteúdo do Usuário --- */
.user-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease;
    opacity: 1;
}

.user-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.user-hearings-list {
    list-style: none;
    padding: var(--space-3);
    margin: 0;
}

.hearing-item {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-2);
}

.hearing-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* --- Botão Logout --- */
.btn-logout {
    background: linear-gradient(135deg, var(--color-text-muted) 0%, var(--color-text-secondary) 100%);
    color: var(--color-surface);
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-size-sm);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    border: none;
    cursor: pointer;
}

.btn-logout:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* --- Responsividade --- */
@media (max-width: 1200px) {
    .container {
        max-width: 95%;
    }

    .weekly-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--space-3);
        width: 100%;
    }

    h1 {
        font-size: var(--font-size-xl);
    }

    button, .btn-main {
        padding: 14px 30px;
        font-size: var(--font-size-base);
    }

    .user-header h3 {
        font-size: var(--font-size-base);
    }

    .hearing-card {
        flex-direction: column;
        text-align: center;
    }

    .hearing-date-badge {
        width: 100%;
    }

    .kstats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--space-2);
    }

    h1 {
        font-size: var(--font-size-lg);
    }

    .kstats-row {
        grid-template-columns: 1fr;
    }

    .weekly-grid {
        grid-template-columns: 1fr;
    }
}
