/* =============================================================================
   CSS - Sistema de Chat Cleto Gomes
   Layout estilo Claude.ai com sidebar retrátil
   ============================================================================= */

/* Importar Fonte Instrument Sans */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

/* Variáveis */
:root {
    --cleto-red: #A80E0C;
    --cleto-red-dark: #8a0b0a;
    --cleto-gray: #2d2d2d;
    --cleto-gray-dark: #1a1a1a;
    --sidebar-bg: #f9f9f9;
    --sidebar-width: 260px;
    --sidebar-collapsed: 60px;
    --background: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border: #e5e5e5;
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================================================
   Layout Principal
   ============================================================================= */

.app-container {
    display: flex;
    min-height: 100vh;
}

.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
}

/* =============================================================================
   Sidebar
   ============================================================================= */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

/* Ocultar textos quando contraída, manter ícones */
.sidebar.collapsed .nav-text {
    display: none !important;
}

.sidebar.collapsed .logo-container {
    display: none;
}

.sidebar.collapsed .user-name {
    display: none;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .btn-new-chat,
.sidebar.collapsed .nav-item-main {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .sidebar-conversation-item,
.sidebar.collapsed .sidebar-gpt-item {
    justify-content: center;
    padding: 0.6rem;
}

.sidebar.collapsed .nav-section-header {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-section-content {
    display: none !important;
}

.sidebar.collapsed .chevron,
.sidebar.collapsed .btn-add-folder {
    display: none !important;
}

/* Ícones visíveis sempre */
.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Estilo para items principais do menu */
.nav-item-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    margin: 0.25rem 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.nav-item-main:hover {
    background: rgba(168, 14, 12, 0.1);
    color: var(--cleto-red);
}

/* Tooltips para modo contraído */
.sidebar.collapsed .nav-item-main::after,
.sidebar.collapsed .nav-section-header::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    margin-left: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--cleto-gray-dark);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.sidebar.collapsed .nav-item-main:hover::after,
.sidebar.collapsed .nav-section-header:hover::after {
    opacity: 1;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo-container {
    flex: 1;
}

.sidebar-logo {
    height: 50px;
    width: auto;
}

.sidebar-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--border);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.sidebar-expand {
    position: fixed;
    left: 10px;
    top: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    z-index: 99;
    display: none;
    transition: all 0.2s;
}

.sidebar-expand:hover {
    background: var(--sidebar-bg);
}

.sidebar-expand svg {
    width: 18px;
    height: 18px;
}

.sidebar.collapsed ~ .sidebar-expand {
    display: block;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

/* Botão Novo Chat */
.btn-new-chat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem;
    border-radius: 8px;
    background: var(--cleto-red);
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-new-chat:hover {
    background: var(--cleto-red-dark);
}

.btn-new-chat svg {
    width: 18px;
    height: 18px;
}

/* Seções Retráteis */
.nav-section {
    margin: 0.25rem 0;
}

.nav-section.collapsible .nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 0.25rem 0.5rem;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-section.collapsible .nav-section-header:hover {
    background: rgba(168, 14, 12, 0.05);
    color: var(--cleto-red);
}

.nav-section.collapsible .nav-section-header .chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.nav-section.collapsible.collapsed .nav-section-header .chevron {
    transform: rotate(-90deg);
}

.nav-section-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section.collapsible.collapsed .nav-section-content {
    max-height: 0;
}

/* Items Sidebar */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    margin: 0.125rem 0.5rem;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--border);
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Conversas Sidebar */
.sidebar-conversation-wrapper {
    position: relative;
    margin: 0.125rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sidebar-conversation-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    flex: 1;
    min-width: 0;
    position: relative;
}

.sidebar-conversation-item:hover {
    background: var(--border);
}

/* Conversa Ativa */
.sidebar-conversation-item.active {
    background: var(--cleto-red);
    color: white;
    font-weight: 600;
    border-left: 4px solid var(--cleto-red-dark);
}

.sidebar-conversation-item.active:hover {
    background: var(--cleto-red-dark);
}

.sidebar-conversation-item.active svg {
    color: white;
}

.sidebar-conversation-item.active .conversation-meta {
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-conversation-item svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--text-secondary);
}

.btn-conversation-menu {
    display: none;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-conversation-menu:hover {
    background: var(--border);
    color: var(--text-primary);
}

.btn-conversation-menu svg {
    width: 16px;
    height: 16px;
}

.sidebar-conversation-wrapper:hover .btn-conversation-menu {
    display: block;
}

.conversation-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.conversation-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* GPTs Sidebar */
.sidebar-gpt-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0.5rem;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-gpt-item:hover {
    background: var(--border);
}

.gpt-icon-small {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gpt-icon-small svg {
    width: 14px;
    height: 14px;
    color: white;
}

.gpt-info-small {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.gpt-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.gpt-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pastas Sidebar */
.btn-add-folder {
    margin-left: auto;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.btn-add-folder:hover {
    color: var(--cleto-red);
}

.btn-add-folder svg {
    width: 14px;
    height: 14px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.25rem 0.5rem;
    border-radius: 6px;
    background: var(--background);
    transition: background 0.2s;
    position: relative;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.folder-item:hover {
    background: var(--border);
}

.folder-icon {
    display: flex;
    align-items: center;
}

.folder-icon svg {
    width: 16px;
    height: 16px;
}

.folder-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.4rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.folder-actions {
    display: none;
    gap: 0.25rem;
}

.folder-item:hover .folder-actions {
    display: flex;
}

.folder-item:hover .folder-count {
    display: none;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.btn-icon.btn-danger:hover {
    background: rgba(220, 53, 69, 0.1);
    color: var(--error);
}

.btn-icon svg {
    width: 14px;
    height: 14px;
}

.folder-conversations {
    padding-left: 1.5rem;
    margin-top: 0.25rem;
}

.folder-conversation-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.4rem 0.5rem;
    margin: 0.125rem 0;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.folder-conversation-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.folder-conversation-item .conversation-title {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-conversation-item .conversation-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Textos de Estado */
.loading-text,
.empty-text,
.error-text {
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--cleto-red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-item.logout {
    color: var(--error);
}

.nav-item.logout:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* =============================================================================
   Main Content
   ============================================================================= */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* =============================================================================
   Alertas Flash
   ============================================================================= */

.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1100;
    max-width: 400px;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.alert-success { background: var(--success); color: white; }
.alert-error { background: var(--error); color: white; }
.alert-warning { background: var(--warning); color: var(--text-primary); }
.alert-info { background: var(--info); color: white; }

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* =============================================================================
   Autenticação
   ============================================================================= */

.auth-container {
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    margin-bottom: 1rem;
}

.auth-logo img {
    height: 60px;
    width: auto;
}

.auth-header h1,
.auth-header h2 {
    color: var(--cleto-red);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.auth-footer a {
    color: var(--cleto-red);
}

/* =============================================================================
   Formulários
   ============================================================================= */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--background);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--cleto-red);
    box-shadow: 0 0 0 3px rgba(168, 14, 12, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.form-group.checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
}

.form-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-card h3 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* =============================================================================
   Botões
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--cleto-red);
    color: white;
}

.btn-primary:hover {
    background: var(--cleto-red-dark);
}

.btn-secondary {
    background: var(--cleto-gray);
    color: white;
}

.btn-secondary:hover {
    background: var(--cleto-gray-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--sidebar-bg);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* =============================================================================
   Admin Pages
   ============================================================================= */

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.users { background: #e3f2fd; color: #1976d2; }
.stat-icon.gpts { background: #f3e5f5; color: #7b1fa2; }
.stat-icon.conversations { background: #e8f5e9; color: #388e3c; }
.stat-icon.messages { background: #fff3e0; color: #f57c00; }

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1rem;
}

.card-body {
    padding: 1rem 1.5rem;
}

.list-simple {
    list-style: none;
}

.list-simple li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.list-simple li:last-child {
    border-bottom: none;
}

.list-title {
    display: block;
    font-weight: 500;
}

.list-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* =============================================================================
   Tabelas
   ============================================================================= */

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 8px;
    border-collapse: collapse;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--sidebar-bg);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: rgba(0,0,0,0.02);
}

.table .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-primary { background: #cce5ff; color: #004085; }
.badge-secondary { background: #e2e3e5; color: #383d41; }

/* =============================================================================
   Upload de Arquivos
   ============================================================================= */

.file-upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.file-upload-area:hover,
.file-upload-area.highlight {
    border-color: var(--cleto-red);
    background: rgba(168, 14, 12, 0.05);
}

.file-upload-area input[type="file"] {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.file-list {
    list-style: none;
    margin-top: 1rem;
}

.file-list li {
    padding: 0.5rem;
    background: var(--sidebar-bg);
    border-radius: 4px;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* =============================================================================
   Modais
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.checkbox-group {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
}

.checkbox-label:hover {
    background: var(--sidebar-bg);
}

/* =============================================================================
   Chat Index - Seleção de GPTs
   ============================================================================= */

.chat-index-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.index-welcome {
    text-align: center;
    margin-bottom: 3rem;
}

.index-welcome .welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    color: var(--cleto-red);
}

.index-welcome .welcome-icon svg {
    width: 100%;
    height: 100%;
}

.index-welcome h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.index-welcome p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

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

.gpt-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    display: flex;
    gap: 1rem;
}

.gpt-card:hover {
    border-color: var(--cleto-red);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.gpt-icon {
    width: 48px;
    height: 48px;
    background: var(--cleto-red);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gpt-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.gpt-info h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.gpt-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.gpt-category {
    display: inline-block;
    background: var(--sidebar-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* =============================================================================
   Chat Container
   ============================================================================= */

.chat-container {
    display: flex;
    height: 100vh;
}

/* Chat Sidebar - REMOVIDA - Conversas agora apenas na sidebar principal */
/*
.chat-sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.chat-sidebar .sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-sidebar .sidebar-header h3 {
    font-size: 1rem;
}

.conversation-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-list li {
    margin-bottom: 0.25rem;
}
*/

.conversation-list a {
    display: block;
    padding: 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.conversation-list a:hover {
    background: var(--border);
}

.conversation-list li.active a {
    background: rgba(168, 14, 12, 0.1);
}

.conv-title {
    display: block;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-sidebar .sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
}

.btn-toggle-sidebar svg {
    width: 24px;
    height: 24px;
}

.chat-header-info h2 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.chat-header-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.welcome-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 1.5rem;
    color: var(--cleto-red);
}

.welcome-icon svg {
    width: 100%;
    height: 100%;
}

.chat-welcome h3 {
    font-size: 1.75rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.chat-welcome p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.message {
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--cleto-red);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Formatação Markdown nas mensagens */
.message-content p {
    margin: 0 0 0.75rem 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child {
    margin-top: 0;
}

.message-content h2 { font-size: 1.25rem; }
.message-content h3 { font-size: 1.1rem; }
.message-content h4 { font-size: 1rem; }

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.08);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: var(--cleto-gray);
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.85rem;
}

.message-content ul,
.message-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

/* Listas aninhadas - suporte adequado */
.message-content ul ul,
.message-content ul ol,
.message-content ol ul,
.message-content ol ol {
    margin: 0.25rem 0;
    padding-left: 2rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

/* Blockquotes - para recuos/citações */
.message-content blockquote {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    padding-left: 1.5rem;
    border-left: 4px solid var(--cleto-red);
    background: rgba(168, 14, 12, 0.05);
    font-style: normal;
}

.message.user .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

/* Suporte a recuos/indentação para texto comum */
.message-content .indented {
    display: block;
}

/* Níveis de indentação - valores pequenos para evitar overflow */
.message-content .indented[data-indent="1"] { padding-left: 0.8em; }
.message-content .indented[data-indent="2"] { padding-left: 1.6em; }
.message-content .indented[data-indent="3"] { padding-left: 2.4em; }
.message-content .indented[data-indent="4"] { padding-left: 3.2em; }
.message-content .indented[data-indent="5"] { padding-left: 4em; }

/* Responsivo: recuos ainda menores em telas pequenas */
@media (max-width: 768px) {
    .message-content .indented[data-indent="1"] { padding-left: 0.6em; }
    .message-content .indented[data-indent="2"] { padding-left: 1.2em; }
    .message-content .indented[data-indent="3"] { padding-left: 1.8em; }
    .message-content .indented[data-indent="4"] { padding-left: 2.4em; }
    .message-content .indented[data-indent="5"] { padding-left: 3em; }
}

.message-content a {
    color: var(--cleto-red);
    text-decoration: underline;
}

.message.user .message-content a {
    color: white;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}

.message-content table th,
.message-content table td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.message-content table th {
    background: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.message-content table tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.message.user .message-content table th,
.message.user .message-content table td {
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content table th {
    background: rgba(255, 255, 255, 0.15);
}

.message.user .message-content table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.1);
}

.message-attachments {
    margin-top: 0.5rem;
}

.attachment-badge {
    display: inline-block;
    background: rgba(0,0,0,0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Message Actions (Download button, etc) */
.message-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-download-docx {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: var(--cleto-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-download-docx:hover {
    background: #8a0b0a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(168, 14, 12, 0.3);
}

.btn-download-docx:active {
    transform: translateY(0);
}

.btn-download-docx svg {
    flex-shrink: 0;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0 1.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--cleto-red);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.typing-timer {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: none !important;
    animation: none !important;
}

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
}

.btn-attach,
.btn-send {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    flex-shrink: 0;
}

.btn-attach:hover,
.btn-send:hover {
    color: var(--cleto-red);
}

.btn-attach svg,
.btn-send svg {
    width: 20px;
    height: 20px;
}

#messageInput {
    flex: 1;
    border: none;
    background: none;
    padding: 0.5rem;
    font-size: 1rem;
    resize: none;
    min-height: 24px;
    max-height: 120px;
}

#messageInput:focus {
    outline: none;
}

.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.file-preview-item {
    background: var(--sidebar-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-preview-item button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--error);
    font-size: 1rem;
}

/* =============================================================================
   Empty State
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 1rem;
}

/* =============================================================================
   Utilitários
   ============================================================================= */

.text-muted {
    color: var(--text-secondary);
}

.info-list {
    list-style: none;
}

.info-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.info-list li:last-child {
    border-bottom: none;
}

/* =============================================================================
   Responsivo
   ============================================================================= */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
    }

    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    .sidebar-expand {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .chat-container {
        flex-direction: column;
    }

    .chat-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 900;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }

    .chat-sidebar.active {
        display: flex;
    }

    .btn-toggle-sidebar {
        display: block;
    }

    .message {
        max-width: 90%;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .table .actions {
        flex-direction: column;
    }

    .chat-index-container {
        padding: 2rem 1rem;
    }
}

@media (max-width: 576px) {
    .admin-container {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .form-card {
        padding: 1.5rem;
    }

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

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

/* =============================================================================
   Prompts Personalizados
   ============================================================================= */

/* Botão adicionar prompt */
.btn-add-prompt {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.btn-add-prompt:hover {
    background: rgba(168, 14, 12, 0.1);
    color: var(--cleto-red);
}

.btn-add-prompt svg {
    width: 16px;
    height: 16px;
}

/* Container de prompts */
.prompts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.prompts-subsection {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompts-subsection-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 0.75rem;
}

.prompt-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Item de prompt */
.prompt-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.prompt-item:hover {
    border-color: var(--cleto-red);
    box-shadow: 0 2px 8px rgba(168, 14, 12, 0.1);
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.prompt-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.prompt-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(168, 14, 12, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.prompt-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.prompt-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    white-space: nowrap;
}

.prompt-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.prompt-public-badge,
.prompt-private-badge {
    font-size: 1rem;
    opacity: 0.7;
}

/* Botão usar prompt */
.btn-use-prompt {
    background: var(--cleto-red);
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-use-prompt:hover {
    background: var(--cleto-red-dark);
    transform: translateY(-1px);
}

.btn-use-prompt svg {
    width: 16px;
    height: 16px;
}

/* Modal de prompt */
.modal-large {
    max-width: 700px;
    width: 90%;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--cleto-red);
    box-shadow: 0 0 0 3px rgba(168, 14, 12, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Notificações */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 350px;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-success {
    border-left: 4px solid var(--success);
    color: var(--success);
}

.notification-error {
    border-left: 4px solid var(--error);
    color: var(--error);
}

.notification-info {
    border-left: 4px solid var(--info);
    color: var(--info);
}

/* Empty state */
.empty-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 1rem;
    font-style: italic;
}

/* Responsividade para prompts */
@media (max-width: 768px) {
    .prompt-header {
        flex-direction: column;
    }

    .prompt-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .modal-large {
        max-width: 95%;
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }
}

/* =============================================================================
   Menu de Contexto de Conversas
   ============================================================================= */

.conversation-context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 1000;
    animation: slideIn 0.2s ease;
}

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

.context-menu-header {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.context-menu-items {
    padding: 0.5rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.context-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.context-menu-item:hover {
    background: rgba(168, 14, 12, 0.05);
    color: var(--cleto-red);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.context-menu-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.context-menu-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

/* Botão de ícone genérico */
.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(168, 14, 12, 0.1);
    color: var(--cleto-red);
}

.btn-icon.btn-danger:hover {
    background: rgba(220, 53, 69, 0.1);
    color: var(--error);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}
