/* =========================================================
   INTRANET — Estilos principales
   ========================================================= */

/* ── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w:    240px;
    --color-bg:     #eff6ff;
    --color-surface:#ffffff;
    --color-border: #bfdbfe;
    --color-sidebar:#1e3a8a;
    --color-sidebar-hover: #1d4ed8;
    --color-accent: #2563eb;
    --color-accent-dark: #1d4ed8;
    --color-danger: #ef4444;
    --color-danger-dark: #dc2626;
    --color-success:#22c55e;
    --color-warning:#f59e0b;
    --color-text:   #0f172a;
    --color-muted:  #64748b;
    --radius:       8px;
    --radius-lg:    12px;
    --shadow:       0 1px 3px rgba(37,99,235,.10), 0 1px 2px rgba(37,99,235,.06);
    --shadow-md:    0 4px 6px -1px rgba(37,99,235,.12), 0 2px 4px -1px rgba(37,99,235,.07);
    --shadow-lg:    0 10px 15px -3px rgba(37,99,235,.12), 0 4px 6px -2px rgba(37,99,235,.06);
    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT PRINCIPAL ────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #ffffff;
    border-bottom: 3px solid var(--color-accent);
}

.sidebar-logo-img {
    max-width: 190px;
    width: 100%;
    height: auto;
    max-height: 54px;
    object-fit: contain;
    display: block;
}

/* fallback si no carga la imagen */
.logo-icon { font-size: 28px; }
.logo-title { display: block; font-size: 16px; font-weight: 700; color: #f1f5f9; }
.logo-sub   { display: block; font-size: 11px; color: #93c5fd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #bfdbfe;
    font-weight: 500;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--color-accent); color: #fff; }
.nav-icon { font-size: 16px; flex-shrink: 0; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.12);
    background: rgba(0,0,0,.15);
}

.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.2);
}
.user-info { flex: 1; min-width: 0; }
.user-name  { display: block; font-size: 13px; font-weight: 600; color: #f0f9ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 11px; color: #93c5fd; }

.logout-btn {
    color: #93c5fd;
    font-size: 18px;
    text-decoration: none;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s;
}
.logout-btn:hover { color: var(--color-danger); text-decoration: none; }

/* ── MAIN CONTENT ────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(37,99,235,.08);
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-sidebar);
    white-space: nowrap;
}

.top-bar-logo img {
    max-height: 40px;
    width: auto;
}

.content-area {
    padding: 24px;
    flex: 1;
}

/* ── SEARCH ──────────────────────────────────────────── */
.search-form {
    display: flex;
    gap: 6px;
    flex: 1;
    max-width: 400px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: #f0f7ff;
}
.search-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); background: #fff; }

.search-btn {
    padding: 8px 12px;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s;
}
.search-btn:hover { background: var(--color-accent-dark); }

.inline-search {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 500px;
}

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .1s, opacity .15s;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-dark); opacity: 1; }
.btn-secondary { background: #eff6ff; color: var(--color-sidebar); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #dbeafe; opacity: 1; }
.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-dark); }

.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── ALERTS ──────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #d97706; border: 1px solid #fed7aa; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-icon    { font-weight: 800; font-size: 15px; }

/* ── BADGES ──────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-default { background: #dbeafe; color: #1e40af; }
.badge-pdf     { background: #fef2f2; color: #dc2626; }
.badge-word    { background: #eff6ff; color: #1d4ed8; }
.badge-excel   { background: #f0fdf4; color: #15803d; }
.badge-ppt     { background: #fff7ed; color: #c2410c; }
.badge-img     { background: #fdf4ff; color: #7e22ce; }
.badge-txt     { background: #f8fafc; color: #475569; }
.badge-zip     { background: #fefce8; color: #854d0e; }

/* ── STATS GRID ──────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    border-top: 3px solid var(--color-accent);
}

.stat-number {
    font-size: 36px;
    font-weight: 800;
    color: var(--color-accent);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stat-action {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

/* ── SECTION HEADER ──────────────────────────────────── */
.section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-left { flex: 1; }
.section-actions { display: flex; gap: 8px; flex-shrink: 0; }

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-sidebar);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-desc { font-size: 13px; color: var(--color-muted); margin-top: 2px; }

.subsection-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--color-accent);
    margin-bottom: 10px;
    margin-top: 20px;
}

/* ── CATEGORIES GRID ─────────────────────────────────── */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.categories-grid-sm { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.category-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    transition: box-shadow .15s, border-color .15s, transform .15s;
    text-decoration: none;
    color: var(--color-text);
}
.category-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-accent);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--color-text);
    background: #f0f7ff;
}
.category-card-sm { padding: 10px 14px; }

.category-icon { font-size: 28px; flex-shrink: 0; }
.category-info { flex: 1; min-width: 0; }
.category-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-meta { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.category-desc { font-size: 12px; color: var(--color-muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.category-arrow { color: var(--color-accent); font-size: 20px; flex-shrink: 0; }

/* ── FILES GRID ──────────────────────────────────────── */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.file-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.file-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--color-accent); }

.file-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.file-icon    { font-size: 22px; }
.file-icon-lg { font-size: 36px; }

.file-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.file-name-lg { font-size: 15px; font-weight: 600; }

.file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
    color: var(--color-muted);
}

.file-desc {
    font-size: 12px;
    color: var(--color-muted);
    font-style: italic;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.file-info { flex: 1; min-width: 0; }
.file-info .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info .file-meta { margin-top: 4px; }

/* ── FILES LIST VIEW ─────────────────────────────────── */
.files-grid.list-view {
    grid-template-columns: 1fr;
}
.files-grid.list-view .file-card {
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
}
.files-grid.list-view .file-card-top { flex-direction: column; width: 40px; align-items: center; }
.files-grid.list-view .file-name { -webkit-line-clamp: 1; }
.files-grid.list-view .file-info { flex: 1; }
.files-grid.list-view .file-actions { margin-top: 0; flex-wrap: nowrap; }

/* ── VIEW CONTROLS ───────────────────────────────────── */
.view-controls {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}
.view-btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: var(--radius);
    font-size: 12px;
    cursor: pointer;
    color: var(--color-muted);
    transition: background .15s, color .15s;
}
.view-btn.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* ── RECENT LIST ─────────────────────────────────────── */
.recent-list {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    transition: background .1s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #eff6ff; }
.recent-icon { font-size: 20px; flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta { display: block; font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.recent-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ── BREADCRUMB ──────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 20px;
    font-size: 13px;
}
.breadcrumb-item { color: var(--color-muted); }
.breadcrumb-item.active { color: var(--color-sidebar); font-weight: 600; }
.breadcrumb-sep { color: var(--color-accent); }
a.breadcrumb-item:hover { color: var(--color-accent); text-decoration: none; }

/* ── CARD ────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    max-width: 700px;
}
.card-danger { border-color: #fecaca; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #f0f7ff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-header h2 { font-size: 16px; font-weight: 700; color: var(--color-sidebar); }

.card-body { padding: 20px; }

/* ── FORMS ───────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--color-sidebar); margin-bottom: 6px; }
.required    { color: var(--color-danger); }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-surface);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: var(--font);
}
.form-control:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.input-group { display: flex; }
.input-group .form-control { border-right: none; border-radius: var(--radius) 0 0 var(--radius); }
.input-addon {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    background: #eff6ff;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    font-size: 14px;
    transition: background .15s;
}
.input-addon:hover { background: #dbeafe; }

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; }
.form-check input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--color-accent); }

.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 4px; }

/* ── DRAG & DROP UPLOAD ──────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    margin-bottom: 20px;
    transition: border-color .15s, background .15s;
    cursor: pointer;
    background: #f8fbff;
}
.drop-zone.drag-over {
    border-color: var(--color-accent);
    background: rgba(37,99,235,.05);
}
.drop-zone input[type="file"] { display: none; }
.drop-zone-icon { font-size: 48px; margin-bottom: 12px; }
.drop-zone-text { font-size: 15px; font-weight: 600; color: var(--color-sidebar); margin-bottom: 6px; }
.drop-zone-hint { font-size: 12px; color: var(--color-muted); margin-bottom: 14px; }

.file-preview-list {
    background: #eff6ff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px;
    margin-bottom: 16px;
}
.preview-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background .1s;
}
.preview-item:hover { background: #dbeafe; }
.preview-item-icon { font-size: 18px; }
.preview-item-name { flex: 1; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-item-size { font-size: 11px; color: var(--color-muted); }
.preview-item-remove { color: var(--color-danger); cursor: pointer; padding: 2px 6px; border-radius: 4px; }

.progress-bar { height: 6px; background: #dbeafe; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: var(--color-accent); border-radius: 3px; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--color-muted); text-align: center; }

/* ── TABLE ───────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
}
.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #1e40af;
    background: #eff6ff;
    border-bottom: 2px solid var(--color-border);
}
.data-table td {
    padding: 12px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f0f7ff; }

.action-btns { display: flex; gap: 6px; }
.link { color: var(--color-accent); font-weight: 500; }
.text-muted { color: var(--color-muted); }
.mono { font-family: 'Courier New', monospace; font-size: 12px; color: var(--color-muted); }
.meta-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── FILE INFO BOX ───────────────────────────────────── */
.file-info-box {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px;
    background: #eff6ff;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
}

/* ── DANGER TEXT ─────────────────────────────────────── */
.danger-text {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: #dc2626;
    margin-bottom: 20px;
}

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.empty-state p { color: var(--color-muted); margin-bottom: 16px; font-size: 14px; }

/* ── LOGIN PAGE ──────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(30,58,138,.30), 0 4px 12px rgba(30,58,138,.20);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 28px; }

.login-logo-img {
    max-width: 220px;
    width: 100%;
    height: auto;
    max-height: 70px;
    object-fit: contain;
    display: block;
    margin: 0 auto 16px;
}

.login-logo   { font-size: 48px; margin-bottom: 10px; }
.login-title  { font-size: 22px; font-weight: 800; color: var(--color-sidebar); }
.login-subtitle { font-size: 13px; color: var(--color-muted); margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form .btn { margin-top: 4px; }

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--color-muted);
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .top-bar { flex-wrap: wrap; }
    .page-title { font-size: 16px; }
    .search-form { max-width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .categories-grid { grid-template-columns: 1fr; }
    .files-grid { grid-template-columns: 1fr; }
    .content-area { padding: 16px; }
}
