/* =========================
   INSTITUTIONAL STYLES (Merged from CAI)
   ========================= */
:root {
    --azul: #0b1d3a;
    --warn: #facc15;
    --bg-color: #f5f7fb;
    --card-bg: #ffffff;
    --text-color: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Mappings for existing components */
    --primary-color: var(--azul);
    --primary-hover: #1e3a8a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =========================
   HEADER & LAYOUT
   ========================= */
.site-header {
    background: var(--azul);
    color: #d9e2f2;
    border-bottom: 4px solid var(--warn);
    height: 75px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    width: 100%;
    padding: 0 1.5rem;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: inherit;
}

.user-info-header {
    color: #fff;
}

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: auto;
}

/* SIDEBAR (Adapted to Institutional) */
.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--azul);
    color: var(--warn);
    border: 2px solid var(--warn);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.username {
    font-weight: 600;
    color: var(--azul);
    font-size: 0.9rem;
}

.role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: #eff6ff;
    color: var(--azul);
}

.nav-item.active {
    background: rgba(11, 29, 58, 0.05);
    font-weight: 700;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #ef4444;
    text-decoration: none;
    margin-top: auto;
    font-weight: 500;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    overflow: hidden;
}

/* TOOLBAR */
.toolbar {
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breadcrumbs {
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crumb {
    cursor: pointer;
    transition: color 0.2s;
}

.crumb:hover {
    color: var(--azul);
}

.crumb.active {
    color: var(--azul);
    font-weight: 700;
    cursor: default;
}

.crumb::after {
    content: '/';
    margin: 0 0.5rem;
    color: #cbd5e1;
}

.crumb:last-child::after {
    display: none;
}

/* ACTIONS */
.actions {
    display: flex;
    gap: 0.5rem;
}

/* FILE GRID */
.file-grid {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.file-item {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    position: relative;
}

.file-item:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--azul);
    transform: translateY(-2px);
}

.file-item .btn-delete-file {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 10;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.file-item:hover .btn-delete-file {
    opacity: 1;
}

.file-item .btn-delete-file:hover {
    background-color: #fee2e2;
    transform: scale(1.1);
}

.file-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.file-icon.folder {
    color: var(--warn);
}

.file-icon.pdf {
    color: #ef4444;
}

.file-icon.word {
    color: #2563eb;
}

.file-icon.excel {
    color: #10b981;
}

.file-icon.image {
    color: #8b5cf6;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    text-align: center;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: auto;
    padding-top: 0.5rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--azul);
    color: #fff;
}

.btn-primary:hover {
    background: #1e3a8a;
    box-shadow: 0 4px 12px rgba(11, 29, 58, 0.2);
}

.btn-outline {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #475569;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: var(--azul);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: #f1f5f9;
}

/* MODALS */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 29, 58, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 14px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-title {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* AUTH / LOGIN SPECIFIC */
body.login-body {
    padding: 0;
    height: 100vh;
}

.login-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.login-form-wrapper {
    flex: 1;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-header {
    margin-bottom: 2rem;
}

.login-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--azul);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: #64748b;
    margin: 0;
    font-size: 0.95rem;
}

.login-image {
    flex: 1.5;
    background-color: var(--azul);
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: flex-end;
    padding: 4rem;
    color: #fff;
}

.login-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(11, 29, 58, 0.9), rgba(11, 29, 58, 0.4));
}

.login-caption {
    position: relative;
    z-index: 2;
    max-width: 600px;
}

.login-caption h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.login-caption p {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

@media(max-width: 900px) {
    .login-image {
        display: none;
    }
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #334155;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 0.95rem;
    transition: box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(11, 29, 58, 0.1);
}

.alert {
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* =========================
   FOOTER INSTITUCIONAL
   ========================= */
.site-footer {
    margin-top: auto;
    background: #0b1d3a;
    color: #d9e2f2;
    border-top: 4px solid #facc15;
    flex-shrink: 0;
    z-index: 1000;
}

.footer-shell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-logo {
    height: 42px;
    width: auto;
}

.footer-text strong {
    color: #fff;
    font-size: 15px;
    display: block;
}

.footer-text small {
    color: #cbd5e1;
    font-size: 12px;
}

.footer-right {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-right a {
    color: #d9e2f2;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    font-size: 0.9rem;
}

.footer-right a:hover {
    color: #facc15;
}

.footer-copy {
    text-align: center;
    font-size: 0.85rem;
    color: #9fb3d6;
    padding: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #08162e;
}

@media (max-width: 768px) {
    .footer-shell {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .footer-right {
        justify-content: center;
    }
}