/* --- VARIABLES: MODERN HERITAGE THEME --- */
:root {
    /* Colores Principales */
    --primary: #0f172a;
    /* Azul pizarra muy oscuro (Fondo sidebar) */
    --primary-light: #1e293b;
    /* Azul pizarra más claro (Hover sidebar) */
    --accent: #d4af37;
    /* Oro Metálico (Heritage) */
    --accent-glow: rgba(212, 175, 55, 0.4);

    /* Fondo y Superficies */
    --bg-dark: #020617;
    /* Casi negro (Fondo App) */
    --glass: rgba(15, 23, 42, 0.7);
    /* Cristal */
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);

    /* Texto */
    --text-main: #f8fafc;
    /* Blanco Roto */
    --text-muted: #94a3b8;
    /* Gris Azulado */

    /* Fuentes */
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', system-ui, sans-serif;
    /* Inter es más moderna que Roboto */
}

/* --- RESET & BASE --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    /* Imagen de fondo sutil con overlay oscuro */
    background-image: linear-gradient(to bottom, rgba(2, 6, 23, 0.85), rgba(2, 6, 23, 0.95)), url('../IMG_9486.jpeg');
    background-size: cover;
    background-attachment: fixed;
    color: var(--text-main);
    height: 100vh;
    display: flex;
    overflow: hidden;
    /* Evita scroll en body, lo manejamos en content */
}

/* GLOBAL INPUT STYLE FIX */
input,
textarea,
select {
    color: white !important;
}

/* Style for inputs inside cards (Login, Register, Upload) */
.doc-card input[type="text"],
.doc-card input[type="password"],
.doc-card input[type="email"],
.doc-card select,
.doc-card textarea {
    padding: 12px 15px !important;
    /* Taller inputs */
    margin-bottom: 15px !important;
    /* Proper spacing */
    border-radius: 6px !important;
    font-size: 1rem !important;
    line-height: normal !important;
    height: auto !important;
    /* Let padding define height */
    width: 100%;
}

.doc-card textarea {
    min-height: 80px;
    resize: vertical;
}

/* --- LAYOUT: SIDEBAR + CONTENT --- */
.app-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    border-right: var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

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

.logo-text {
    font-family: var(--font-heading);
    color: var(--accent);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.2;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    /* Empuja el footer del sidebar abajo */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* Estado Activo / Hover */
.nav-item:hover,
.nav-item.active {
    background: var(--primary-light);
    color: var(--text-main);
    border-left: 3px solid var(--accent);
}

.sidebar-footer {
    border-top: var(--glass-border);
    padding-top: 1.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

/* Header (Search & Actions) */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: var(--glass-border);
    backdrop-filter: blur(10px);
}

.search-container {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 8px 15px;
    border: 1px solid transparent;
    transition: border-color 0.3s;
    width: 400px;
}

.search-container:focus-within {
    border-color: var(--accent);
}

.search-input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-size: 0.95rem;
    margin-left: 10px;
}

/* --- FILTER BAR --- */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-bar select,
.filter-bar button {
    height: 48px !important;
    /* Más alto */
    padding: 0 20px !important;
    font-size: 1rem !important;
    border-radius: 8px !important;
    background: rgba(30, 41, 59, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-bar select:hover,
.filter-bar button:hover {
    background: rgba(30, 41, 59, 0.9) !important;
    border-color: var(--accent) !important;
}

/* --- DOCUMENT GRID --- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.doc-card {
    background: rgba(30, 41, 59, 0.4);
    border: var(--glass-border);
    border-radius: 12px;
    padding: 1.2rem;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.doc-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(212, 175, 55, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.file-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
}

.icon-pdf {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.icon-img {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.card-title {
    font-family: var(--font-heading);
    color: var(--text-main);
    font-size: 1.1rem;
    margin-top: 10px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent);
    border: 1px solid rgba(212, 175, 55, 0.2);
}

/* FAB (Floating Action Button) */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #b8860b);
    color: black;
    font-size: 2rem;
    border: none;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
}

/* --- UTILS --- */
.hidden {
    display: none !important;
}

.text-gold {
    color: var(--accent);
}

/* --- MODAL (Reused/Styled) --- */
/* --- MODAL (Reused/Styled) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Slightly darker */
    backdrop-filter: blur(8px);
    /* More blur */
    z-index: 2000;
    /* High z-index */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    /* Prevent interaction when hidden */
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--accent);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    /* Animation */
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        z-index: 100;
        height: 100vh;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        padding: 1rem;
    }

    .top-bar {
        margin-bottom: 1rem;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }


    .search-container {
        width: 100%;
    }
}

/* --- CHAT MODAL STYLES --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--primary-light);
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0,0,0,0.2);
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.user-message {
    align-self: flex-end;
    background-color: var(--primary); /* Blue/Dark from theme */
    color: white;
    border-bottom-right-radius: 0.25rem;
    border: 1px solid var(--glass-border);
}

.ai-message {
    align-self: flex-start;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-bottom-left-radius: 0.25rem;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 0.5rem;
    background: var(--primary-light);
}

.chat-input-area input[type="text"] {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 0 !important; /* Override global input style */
}

.chat-input-area input[type="text"]:focus {
    border-color: var(--accent);
}

.send-btn {
    background-color: var(--accent);
    color: black;
    border: none;
    padding: 0 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.send-btn:hover {
    filter: brightness(1.1);
}

.send-btn:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 1rem;
    margin-bottom: 5px;
    font-style: italic;
}