/**
 * Floopy APS — User Dashboard styles
 */

.floopy-user-dashboard {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: inherit;
    color: var(--floopy-text, #2c3e50);
}

.floopy-user-dashboard__greeting {
    margin-bottom: 1.5rem;
}

.floopy-user-dashboard__greeting h2 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--floopy-text, #2c3e50);
}

/* KPIs */
.floopy-user-dashboard__kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.floopy-user-kpi {
    background: #fff;
    border: 1px solid var(--floopy-border, #e1e4e8);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.floopy-user-kpi__label {
    font-size: 0.8rem;
    color: var(--floopy-text-light, #7f8c8d);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Badge informativo "i" con tooltip CSS-only.
   Se muestra al hacer hover, focus, o focus-within (para teclado). */
.floopy-user-kpi__info {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    outline: none;
}

.floopy-user-kpi__info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d7dee4;
    color: #50575e;
    font-size: 10px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}

.floopy-user-kpi__info:hover .floopy-user-kpi__info-icon,
.floopy-user-kpi__info:focus .floopy-user-kpi__info-icon {
    background: var(--floopy-primary, #3498db);
    color: #fff;
}

.floopy-user-kpi__info-tip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    min-width: 220px;
    max-width: 280px;
    padding: 10px 12px;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
    text-transform: none;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
    z-index: 20;
    white-space: normal;
    text-align: left;
}

/* Flechita apuntando al icono. */
.floopy-user-kpi__info-tip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top: 0;
    border-bottom-color: #1f2937;
}

.floopy-user-kpi__info:hover .floopy-user-kpi__info-tip,
.floopy-user-kpi__info:focus .floopy-user-kpi__info-tip,
.floopy-user-kpi__info:focus-within .floopy-user-kpi__info-tip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0s;
}

/* En pantallas estrechas anclamos el tooltip al borde derecho del icono para
   que no se salga del viewport. */
@media (max-width: 480px) {
    .floopy-user-kpi__info-tip {
        left: auto;
        right: 0;
        transform: translateX(0) translateY(-4px);
        min-width: 180px;
    }
    .floopy-user-kpi__info:hover .floopy-user-kpi__info-tip,
    .floopy-user-kpi__info:focus .floopy-user-kpi__info-tip,
    .floopy-user-kpi__info:focus-within .floopy-user-kpi__info-tip {
        transform: translateX(0) translateY(0);
    }
    .floopy-user-kpi__info-tip::before {
        left: auto;
        right: 4px;
        transform: translateX(0);
    }
}

.floopy-user-kpi__value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--floopy-primary, #3498db);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.floopy-user-kpi__value--gray {
    color: #7f8c8d;
    font-size: 1.3rem;
}

.floopy-user-kpi__hint {
    font-size: 0.85rem;
    color: var(--floopy-text-light, #7f8c8d);
}

.floopy-user-kpi__hint a {
    color: var(--floopy-primary, #3498db);
    text-decoration: none;
}

/* Acciones */
.floopy-user-dashboard__actions {
    background: #fff;
    border: 1px solid var(--floopy-border, #e1e4e8);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.floopy-user-dashboard__actions h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.floopy-user-dashboard__btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.floopy-btn--danger {
    background: #fff;
    color: var(--floopy-danger, #e74c3c);
    border: 1px solid var(--floopy-danger, #e74c3c);
}

.floopy-btn--danger:hover:not(:disabled) {
    background: var(--floopy-danger, #e74c3c);
    color: #fff;
}

.floopy-user-dashboard__note {
    margin: 1rem 0 0;
    padding: 0.75rem 1rem;
    background: #fff9e6;
    border: 1px solid #f0c674;
    border-radius: 6px;
    color: #8a6d3b;
    font-size: 0.9rem;
}

/* Cards */
.floopy-user-dashboard__card {
    background: #fff;
    border: 1px solid var(--floopy-border, #e1e4e8);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.floopy-user-dashboard__card h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--floopy-text, #2c3e50);
}

/* Tablas */
.floopy-user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.floopy-user-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--floopy-border, #e1e4e8);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--floopy-text-light, #7f8c8d);
}

.floopy-user-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.floopy-user-table tr:last-child td {
    border-bottom: none;
}

.floopy-user-table tr.is-consumed {
    opacity: 0.5;
}

.floopy-user-table code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 640px) {
    .floopy-user-dashboard__btns {
        flex-direction: column;
    }

    .floopy-user-dashboard__btns .floopy-btn {
        width: 100%;
        justify-content: center;
    }

    .floopy-user-table {
        font-size: 0.8rem;
    }

    .floopy-user-table th,
    .floopy-user-table td {
        padding: 0.5rem;
    }
}

/* ==========================================================================
   Mis archivos (Fase 5.5a)
   ========================================================================== */
.floopy-my-files__header {
    margin-bottom: 1rem;
}
.floopy-my-files__lead {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}
.floopy-my-files__list[data-state="loading"],
.floopy-my-files__list[data-state="empty"],
.floopy-my-files__list[data-state="error"] {
    padding: 2rem 1rem;
    text-align: center;
    color: #7f8c8d;
}
.floopy-my-files__empty a {
    color: #3498db;
    text-decoration: underline;
}
.floopy-my-files__error {
    color: #e74c3c;
}
.floopy-my-files__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.floopy-my-files__card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.floopy-my-files__card:hover {
    border-color: #3498db;
    box-shadow: 0 2px 12px rgba(52, 152, 219, 0.12);
}
.floopy-my-files__card.is-expired {
    opacity: 0.6;
    background: #fafafa;
}
.floopy-my-files__card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.floopy-my-files__ext {
    display: inline-block;
    padding: 3px 8px;
    background: #3498db;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    border-radius: 4px;
    flex-shrink: 0;
}
.floopy-my-files__name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-grow: 1;
    min-width: 0;
}
.floopy-my-files__meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0.75rem 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}
.floopy-my-files__meta > div {
    text-align: center;
}
.floopy-my-files__meta dt {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #95a5a6;
    margin-bottom: 2px;
}
.floopy-my-files__meta dd {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}
.floopy-my-files__badge {
    display: inline-block;
    padding: 3px 8px;
    background: #e8f5e9;
    color: #1b5e20;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
}
.floopy-my-files__badge.is-warning {
    background: #fff8e1;
    color: #8a6d3b;
}
.floopy-my-files__badge.is-urgent {
    background: #ffebee;
    color: #c62828;
}
.floopy-my-files__card.is-expired .floopy-my-files__badge {
    background: #f0f0f0;
    color: #888;
}
.floopy-my-files__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}
.floopy-my-files__actions .floopy-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    text-align: center;
    justify-content: center;
}
.floopy-my-files__actions .floopy-btn--danger {
    background: #fff;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}
.floopy-my-files__actions .floopy-btn--danger:hover:not(:disabled) {
    background: #e74c3c;
    color: #fff;
}
.floopy-my-files__actions .floopy-btn:disabled {
    background: #f5f5f5;
    color: #999;
    border-color: #e0e0e0;
    cursor: not-allowed;
}
@media (max-width: 640px) {
    .floopy-my-files__grid {
        grid-template-columns: 1fr;
    }
}
.floopy-share-modal__backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 2147483647 !important; /* max int32 - por encima de todo */
    animation: floopyShareFade 0.2s ease;
    margin: 0 !important;
    padding: 0 !important;
}

@keyframes floopyShareFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.floopy-share-modal {
    background: #fff !important;
    border-radius: 12px !important;
    padding: 2rem !important;
    max-width: 500px !important;
    width: 90% !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    position: relative !important;
    margin: 0 !important;
}

.floopy-share-modal h3 {
    margin: 0 0 0.5rem;
    color: #2c3e50;
}

.floopy-share-modal__desc {
    color: #7f8c8d;
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
}

.floopy-share-modal__link-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.floopy-share-modal__input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    background: #f8f9fa;
    color: #2c3e50;
    min-width: 0;
}

.floopy-share-modal__copy-btn {
    padding: 0.6rem 1rem;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}

.floopy-share-modal__copy-btn:hover {
    background: #2980b9;
}

.floopy-share-modal__copy-btn.is-copied {
    background: #27ae60;
}

.floopy-share-modal__info {
    background: #e3f2fd;
    border-left: 3px solid #3498db;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: #2c3e50;
    margin-bottom: 1.5rem;
    border-radius: 4px;
}

.floopy-share-modal__info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.floopy-share-modal__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.floopy-share-modal__actions .floopy-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.floopy-share-modal__actions .floopy-btn--danger {
    background: #fff;
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.floopy-share-modal__actions .floopy-btn--danger:hover {
    background: #e74c3c;
    color: #fff;
}

/* Badge de compartido en cards */
.floopy-my-files__card.is-shared .floopy-my-files__card-head::after {
    content: '🔗';
    margin-left: auto;
    font-size: 14px;
    opacity: 0.7;
    flex-shrink: 0;
}

.floopy-my-files__actions .floopy-btn--share {
    background: #fff;
    color: #3498db;
    border: 1px solid #3498db;
}

.floopy-my-files__actions .floopy-btn--share:hover {
    background: #3498db;
    color: #fff;
}


/* ==========================================================================
   Toggle de vista (cards / list) — Fase 6.2c
   ========================================================================== */
.floopy-my-files__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.floopy-my-files__title-row h3 {
    margin: 0;
    flex-grow: 1;
}

.floopy-my-files__view-toggle {
    display: inline-flex;
    background: #f5f5f5;
    border-radius: 6px;
    padding: 2px;
    border: 1px solid #e1e4e8;
}

.floopy-my-files__view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.15s;
}

.floopy-my-files__view-btn:hover {
    color: #2c3e50;
}

.floopy-my-files__view-btn.is-active {
    background: #fff;
    color: #3498db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.floopy-my-files__view-btn svg {
    display: block;
}

/* ==========================================================================
   Vista de lista (tabla compacta)
   ========================================================================== */
.floopy-my-files__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.floopy-my-files__table thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #95a5a6;
    font-weight: 600;
    border-bottom: 1px solid #e1e4e8;
    background: #fafafa;
}

.floopy-my-files__row {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.12s;
}

.floopy-my-files__row:hover {
    background: #f8fbfd;
}

.floopy-my-files__row.is-expired {
    opacity: 0.6;
    background: #fafafa;
}

.floopy-my-files__row td {
    padding: 0.75rem;
    vertical-align: middle;
    color: #2c3e50;
}

.floopy-my-files__row-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.floopy-my-files__row-name .floopy-my-files__ext {
    flex-shrink: 0;
}

.floopy-my-files__row-filename {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    min-width: 0;
    flex-grow: 1;
}

.floopy-my-files__row-shared-icon {
    font-size: 12px;
    opacity: 0.7;
    flex-shrink: 0;
}

.floopy-my-files__row-actions {
    text-align: right;
    white-space: nowrap;
}

.floopy-my-files__row-actions .floopy-btn {
    display: inline-block;
}

/* Botones pequeños para la fila */
.floopy-btn--sm {
    padding: 4px 10px !important;
    font-size: 0.8rem !important;
    margin: 0 2px;
}

/* ==========================================================================
   Responsive: tabla → cards apiladas en mobile
   ========================================================================== */
@media (max-width: 768px) {
    .floopy-my-files__table,
    .floopy-my-files__table thead,
    .floopy-my-files__table tbody,
    .floopy-my-files__table tr,
    .floopy-my-files__table td {
        display: block;
    }
    .floopy-my-files__table thead {
        display: none;
    }
    .floopy-my-files__row {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        border: 1px solid #e1e4e8;
        border-radius: 8px;
        background: #fff;
    }
    .floopy-my-files__row td {
        padding: 0.35rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .floopy-my-files__row td::before {
        content: attr(data-label);
        font-size: 11px;
        text-transform: uppercase;
        color: #95a5a6;
        font-weight: 600;
        margin-right: 1rem;
    }
    .floopy-my-files__row-name {
        border-bottom: 1px solid #f0f0f0;
        padding-bottom: 0.5rem !important;
        margin-bottom: 0.25rem;
    }
    .floopy-my-files__row-name::before {
        display: none;
    }
    .floopy-my-files__row-actions {
        padding-top: 0.5rem !important;
        border-top: 1px solid #f0f0f0;
        margin-top: 0.25rem;
        text-align: left;
    }
    .floopy-my-files__row-actions::before {
        display: none;
    }
}
