:root {
    --primary-color: #1a237e;
    --secondary-color: #3498db;
    --background-color: #f8f9fa;
    --text-color: #333;
    --border-color: #dee2e6;
    --success-color: #2ecc71;
    --error-color: #e74c3c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    position: relative;
}

/* Estilos para o popup de carregamento */
.loading-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loading-popup.active {
    display: flex;
}

.loading-content {
    background-color: white;
    padding: 30px 50px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.loading-content p {
    margin-top: 15px;
    font-size: 18px;
    font-weight: 500;
    color: var(--primary-color);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.page-header {
    background: #2b3346;
    padding: 2.5rem;
    margin: -1rem -1rem 2rem -1rem;
    text-align: center;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.page-header .logo {
    height: 30px;
    width: auto;
    margin-bottom: 1.75rem;
    filter: brightness(1.02);
}

.page-header .header-title {
    font-size: 1.75rem;
    font-weight: 500;
    margin: 0 0 0.5rem;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.95);
}

.page-header .header-subtitle {
    font-size: 0.95rem;
    font-weight: 400;
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.3px;
}



.results-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.results-title h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-title i {
    font-size: 0.9em;
    opacity: 0.8;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    gap: 2rem;
}

h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
}

.search-form {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 15px;
}

.form-section {
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}

.form-section h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.2em;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.btn {
    background-color: var(--secondary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #2980b9;
}

.form-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.results-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 30px;
    overflow: hidden;
    max-width: 100%;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.results-header h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.4em;
    font-weight: 500;
}

.results-count {
    color: var(--secondary-color);
    font-weight: 500;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    table-layout: fixed;
}

.results-table thead {
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-radius: 8px;
    margin: 20px 0;
}

.results-table th {
    background-color: var(--background-color);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.results-table th:nth-child(1) { width: 13%; }  /* Data */
.results-table th:nth-child(2) { width: 24%; } /* Tribunal */
.results-table th:nth-child(3) { width: 17%; } /* Processo */
.results-table th:nth-child(4) { width: 17%; } /* Tipo */
.results-table th:nth-child(5) { width: 11%; }  /* Meio */
.results-table th:nth-child(6) { width: 18%; } /* Ações */

.results-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
    word-wrap: break-word;
    overflow: visible;
}

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

.results-table tbody tr:hover td {
    background-color: #f0f7ff;
}

.results-table tbody tr.active-row td {
    background-color: #e3f2fd;
}

.results-table tbody tr.result-row {
    cursor: pointer;
}

.results-table th:after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--secondary-color);
    transform: scaleX(0);
    transition: transform 0.3s;
}

.results-table th:hover:after {
    transform: scaleX(1);
}

.results-table td.text-cell {
    max-width: 400px;
    font-size: 0.95em;
    color: #444;
    background-color: #f9f9f9;
    border-radius: 4px;
    padding: 15px;
    overflow: hidden;
    word-wrap: break-word;
}

/* Estilo específico para o estado collapsed */
.results-table td.text-cell.collapsed {
    white-space: normal;
    display: block;
    height: auto;
    min-height: 20px;
    max-height: none !important;
    text-overflow: ellipsis;
}

/* Efeito de gradiente no final do texto truncado */
.results-table td.text-cell:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: linear-gradient(transparent, #f9f9f9);
    pointer-events: none;
}

/* Detailed view styles */
.details-row td {
    padding: 0 !important;
    background: #f8f9fa;
}

.details-con.text-cell {
    position: relative;
    max-height: 100px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-bottom: 40px !important;
    max-width: 100%;
}

.text-cell::after {
    content: '';
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    height: 40px;
    background: linear-gradient(transparent, white);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
}

.text-cell.expanded::after {
    opacity: 0;
}

.details-section {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.details-section:last-child {
    margin-bottom: 20px;
}

.details-section h4 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.details-section h4 i {
    color: var(--secondary-color);
}

.intimacao-texto {
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    white-space: normal;
    line-height: 1.4;
    font-size: 0.95em;
    margin-top: 10px;
    max-height: none;
    overflow: auto;
    text-align: justify;
}

.destinatarios-list,
.advogados-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.destinatarios-list li,
.advogados-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.destinatarios-list li:last-child,
.advogados-list li:last-child {
    border-bottom: none;
}

.destinatario-polo {
    background: #e3f2fd;
    color: var(--secondary-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.advogado-oab {
    color: #666;
    font-size: 0.9em;
}

.additional-info p {
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.status-badge.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.inactive {
    background: #ffebee;
    color: #c62828;
}

.btn-info {
    padding: 6px;
    min-width: 32px;
    background: #f8f9fa;
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
}

.btn-info:hover,
.btn-info.active {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.communication-number {
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
}

.class-code {
    color: #666;
    font-size: 0.85em;
    margin-left: 4px;
}

.no-data {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Improve expand button */
.expand-button {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    padding: 8px 16px;
    background: var(--secondary-color);
    border: none;
    border-radius: 20px;
    color: white;
    position: absolute;
    bottom: 8px;
    right: 8px;
    opacity: 0;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transform: translateY(5px);
}

.expand-button:hover {
    background: #2980b9;
    transform: translateY(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.expand-icon {
    transition: transform 0.3s;
    font-size: 0.85em;
    margin-right: 2px;
}

.text-cell.expanded .expand-icon {
    transform: rotate(180deg);
}

.expand-text, .collapse-text {
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-size: 0.8em;
}

.btn-document {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    padding: 6px 12px;
    background: var(--success-color);
    border: none;
    border-radius: 20px;
    color: white;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    min-width: max-content;
}

.btn-document:hover {
    background: #27ae60;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.results-table td.actions-cell {
    white-space: nowrap;
    text-align: right;
    padding-right: 15px;
    position: relative;
    min-width: 140px;
}

.results-table td.process-number {
    font-family: monospace;
    font-size: 0.9em;
    color: var(--primary-color);
    font-weight: 500;
}

.results-table td.date-cell {
    white-space: nowrap;
    width: 10%;
    font-weight: 500;
}

.results-table td.tribunal-sigla {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.results-table td.type-cell {
    font-weight: 500;
    color: #666;
}

.results-table tr:hover td {
    background-color: #f0f7ff;
}

.results-table td.text-cell.expanded {
    white-space: pre-line;
    cursor: pointer;
}

.results-table td.text-cell.collapsed {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.results-table th {
    background-color: var(--primary-color);
    color: white;
}

.results-table tr:hover {
    background-color: #f5f5f5;
}

/* Pagination styles */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.page-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--secondary-color);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    background: rgba(52, 152, 219, 0.1);
}

.page-link:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-1px);
}

.page-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.total-items {
    color: #666;
    font-size: 0.9em;
}

.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #fde8e8;
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.alert-success {
    background-color: #e8f8f0;
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .search-form {
        padding: 15px;
    }
    
    .results-table {
        display: block;
        overflow-x: auto;
        font-size: 0.9em;
    }
    
    .date-display {
        display: flex;
        flex-direction: column;
        align-items: center;
        white-space: nowrap;
    }
    
    .date-display i {
        margin-right: 0;
        margin-bottom: 3px;
    }
    
    .tribunal-info {
        white-space: normal;
    }
    
    .tribunal-detail {
        font-size: 0.85em;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .type-badge, .meio-badge {
        padding: 4px 6px;
        font-size: 0.85em;
    }
    
    .communication-number {
        font-size: 0.8em;
    }
    
    .btn {
        padding: 5px 8px;
        font-size: 0.85em;
    }
    
    .actions-cell {
        white-space: nowrap;
    }
    
    .details-content {
        padding: 10px;
    }
}
