/* ==========================================================================
   MiNube - Estilos
   ========================================================================== */

:root {
    --mn-primary: #0d6efd;
    --mn-dark: #1a2332;
    --mn-sidebar-w: 260px;
    --mn-navbar-h: 60px;
    --mn-radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f6f8fb;
    color: #1f2937;
}

/* ------------------------------------------------ Páginas de autenticación */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #4568dc 0%, #2b3ea8 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}

.auth-logo {
    font-size: 3rem;
    color: var(--mn-primary);
}

/* -------------------------------------------------------------- Barra superior */

.app-navbar {
    background: var(--mn-dark);
    height: var(--mn-navbar-h);
    z-index: 1030;
}

.app-navbar .navbar-brand {
    color: #fff;
    font-weight: 600;
}

.app-navbar .navbar-brand i {
    color: #6ea8fe;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mn-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .9rem;
}

.search-box {
    position: relative;
    max-width: 520px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa4b2;
    pointer-events: none;
}

.search-box .form-control {
    padding-left: 42px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid transparent;
    color: #fff;
    border-radius: 20px;
}

.search-box .form-control::placeholder {
    color: rgba(255, 255, 255, .55);
}

.search-box .form-control:focus {
    background: #fff;
    color: #1f2937;
    box-shadow: none;
    border-color: var(--mn-primary);
}

.search-box .form-control:focus + i,
.search-box:focus-within i {
    color: #6b7280;
}

.search-box-mobile .form-control {
    background: #fff;
    color: #1f2937;
    border: 1px solid #dde3ec;
}

.search-box-mobile .form-control::placeholder {
    color: #9aa4b2;
}

/* ------------------------------------------------------------------ Layout */

.app-layout {
    display: flex;
    min-height: calc(100vh - var(--mn-navbar-h));
}

.app-sidebar {
    width: var(--mn-sidebar-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e6eaf0;
    padding: 1.25rem;
    position: sticky;
    top: var(--mn-navbar-h);
    height: calc(100vh - var(--mn-navbar-h));
    overflow-y: auto;
}

.app-main {
    flex: 1;
    padding: 1.5rem;
    min-width: 0;
}

.btn-new {
    background: var(--mn-primary);
    color: #fff;
    font-weight: 600;
    border-radius: 24px;
    padding: .6rem 1rem;
    text-align: left;
    box-shadow: 0 2px 8px rgba(13, 110, 253, .3);
}

.btn-new:hover {
    background: #0b5ed7;
    color: #fff;
}

.sidebar-nav .nav-link {
    color: #4b5563;
    border-radius: 8px;
    padding: .55rem .8rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-nav .nav-link:hover {
    background: #f1f5f9;
}

.sidebar-nav .nav-link.active {
    background: #e7f0ff;
    color: var(--mn-primary);
    font-weight: 600;
}

.storage-widget {
    background: #f8fafc;
    border: 1px solid #e6eaf0;
    border-radius: 10px;
    padding: .9rem;
}

.sidebar-backdrop {
    display: none;
}

/* --------------------------------------------------- Zona de arrastre */

.drop-zone {
    position: relative;
    min-height: 400px;
}

.drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(13, 110, 253, .07);
    border: 3px dashed var(--mn-primary);
    border-radius: var(--mn-radius);
    align-items: center;
    justify-content: center;
    color: var(--mn-primary);
}

.drop-overlay i {
    font-size: 3rem;
}

.drop-zone.dragover .drop-overlay {
    display: flex;
}

/* --------------------------------------------------- Cuadrícula de items */

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

.item-card {
    background: #fff;
    border: 1px solid #e6eaf0;
    border-radius: var(--mn-radius);
    padding: 1.1rem .8rem .8rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.item-card:hover {
    border-color: #c7d6ee;
    box-shadow: 0 6px 18px rgba(16, 24, 40, .08);
    transform: translateY(-2px);
}

.item-card.selected {
    border-color: var(--mn-primary);
    background: #f2f7ff;
}

.item-icon {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: .6rem;
}

.item-thumb {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: .6rem;
    background: #f1f5f9;
}

.item-name {
    font-size: .875rem;
    font-weight: 500;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
}

.item-meta {
    font-size: .75rem;
    color: #6b7280;
    margin-top: .25rem;
}

.item-shared-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #198754;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
}

.item-menu-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    border: 0;
    background: transparent;
    color: #9aa4b2;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    opacity: 0;
    transition: opacity .15s;
}

.item-card:hover .item-menu-btn,
.item-row:hover .item-menu-btn {
    opacity: 1;
}

.item-menu-btn:hover {
    background: #eef2f7;
    color: #1f2937;
}

/* -------------------------------------------------------- Vista de lista */

.items-list {
    background: #fff;
    border: 1px solid #e6eaf0;
    border-radius: var(--mn-radius);
    overflow: hidden;
}

.item-row {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    position: relative;
}

.item-row:last-child {
    border-bottom: 0;
}

.item-row:hover {
    background: #f8fafc;
}

.item-row.selected {
    background: #f2f7ff;
}

.item-row .item-icon {
    font-size: 1.5rem;
    margin: 0;
}

.item-row .item-name {
    flex: 1;
    min-height: 0;
    -webkit-line-clamp: 1;
}

.item-row .item-menu-btn {
    position: static;
    flex-shrink: 0;
}

.list-header {
    display: flex;
    gap: .9rem;
    padding: .6rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e6eaf0;
    font-size: .78rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.section-title {
    font-size: .78rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 1.5rem 0 .75rem;
}

.section-title:first-child {
    margin-top: 0;
}

/* ------------------------------------------------------------ Estado vacío */

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 4rem;
    color: #cbd5e1;
}

/* -------------------------------------------------------- Menú contextual */

.context-menu {
    display: none;
    position: fixed;
    z-index: 1080;
    background: #fff;
    border: 1px solid #e6eaf0;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .15);
    padding: .35rem;
    min-width: 190px;
}

.context-menu.show {
    display: block;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: .65rem;
    width: 100%;
    border: 0;
    background: transparent;
    padding: .5rem .75rem;
    border-radius: 6px;
    font-size: .875rem;
    color: #1f2937;
    text-align: left;
}

.context-menu button:hover {
    background: #f1f5f9;
}

.context-menu button.danger {
    color: #dc3545;
}

.context-menu button.danger:hover {
    background: #fdeaec;
}

.context-menu hr {
    margin: .3rem .25rem;
    border-color: #e6eaf0;
}

/* --------------------------------------------------------- Panel de subidas */

.upload-panel {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    width: 380px;
    max-width: calc(100vw - 2rem);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .25);
    overflow: hidden;
    z-index: 1050;
}

.upload-panel-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--mn-dark);
    color: #fff;
    padding: .7rem 1rem;
    font-size: .9rem;
}

.upload-panel-body {
    max-height: 300px;
    overflow-y: auto;
}

.upload-panel.minimized .upload-panel-body {
    display: none;
}

.upload-item {
    padding: .65rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: .82rem;
}

.upload-item:last-child {
    border-bottom: 0;
}

.upload-item .progress {
    height: 4px;
    margin-top: .35rem;
}

.upload-item.done .progress-bar {
    background: #198754;
}

.upload-item.error .progress-bar {
    background: #dc3545;
}

/* ---------------------------------------------------------- Previsualización */

#previewBody img,
#previewBody video {
    max-width: 100%;
    max-height: 75vh;
}

#previewBody iframe {
    width: 100%;
    height: 78vh;
    border: 0;
}

.share-preview img,
.share-preview video {
    max-height: 65vh;
}

.share-navbar {
    background: var(--mn-dark);
}

.share-navbar .navbar-brand {
    color: #fff;
    font-weight: 600;
}

.share-navbar .navbar-brand i {
    color: #6ea8fe;
}

/* ------------------------------------------------------------------ Móvil */

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        top: var(--mn-navbar-h);
        left: 0;
        z-index: 1035;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 10px 40px rgba(0, 0, 0, .2);
    }

    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: var(--mn-navbar-h) 0 0 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1034;
    }

    .app-main {
        padding: 1rem;
    }

    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: .75rem;
    }

    .upload-panel {
        right: .75rem;
        bottom: .75rem;
        left: .75rem;
        width: auto;
    }
}

/* --- Aviso tras iniciar una descarga -------------------------------------
   Mismo lenguaje visual que el panel de subidas, pero arriba a la derecha
   para no taparlo si coinciden los dos. */
.download-panel {
    position: fixed;
    right: 1.25rem;
    top: 4.5rem;
    width: 360px;
    max-width: calc(100vw - 2rem);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .25);
    z-index: 1050;
    animation: dl-in .18s ease-out;
}

.download-panel-body {
    padding: .9rem 1rem;
}

@keyframes dl-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 575.98px) {
    .download-panel {
        right: .75rem;
        left: .75rem;
        width: auto;
    }
}

/* --- Visor de imágenes: flechas y cierre ---------------------------------- */

.preview-close {
    line-height: 1;
    padding: .35rem .6rem;
}

/* Las flechas flotan sobre la imagen, centradas verticalmente. Se apoyan en
   position:relative del contenedor del cuerpo del modal. */
.preview-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, opacity .15s;
}

.preview-nav:hover:not(:disabled) {
    background: rgba(0, 0, 0, .7);
}

/* Al llegar al principio o al final la flecha se apaga en vez de
   desaparecer: así se ve que se acabó la carpeta y no que falla algo. */
.preview-nav:disabled {
    opacity: .2;
    cursor: default;
}

.preview-nav-prev { left: .75rem; }
.preview-nav-next { right: .75rem; }

@media (max-width: 575.98px) {
    .preview-nav {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    .preview-nav-prev { left: .25rem; }
    .preview-nav-next { right: .25rem; }
}
