/* Estilos del Panel de Administración */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.login-bg {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.05;
    z-index: 0;
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(var(--border-light) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
    background-size: 50px 50px;
}

.login-container {
    display: grid;
    grid-template-columns: 500px 1fr;
    max-width: 1200px;
    width: 100%;
    gap: 3rem;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.login-logo img {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.login-logo .logo-icon {
    font-size: 3rem;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
}

.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-error {
    background: #fee;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.alert-success {
    background: #efe;
    color: var(--success);
    border: 1px solid var(--success);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon svg {
    position: absolute;
    left: 1rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

.input-with-icon input {
    padding-left: 3rem;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary);
}

.login-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    justify-content: center;
}

.info-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
}

.info-card svg {
    color: var(--primary);
    margin-bottom: 1rem;
}

.info-card h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.info-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Dashboard */
.admin-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.admin-sidebar {
    background: var(--bg-dark);
    color: white;
    padding: 2rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none;
    color: white;
}

.sidebar-logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.sidebar-logo .logo-icon {
    font-size: 2rem;
}

.sidebar-logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-menu {
    list-style: none;
    padding: 0 1rem;
}

.sidebar-menu li {
    margin-bottom: 0.5rem;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-menu a.active {
    background: var(--primary);
    color: white;
}

.admin-main {
    padding: 2rem;
    overflow-x: hidden;
}

.admin-header {
    background: white;
    padding: 1.5rem 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.stat-info h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

/* Tablas */
.table-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    padding: 1rem 1.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
}

.data-table tr:hover {
    background: var(--bg-secondary);
}

.badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
}

.badge-success {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #15803d;
    border: 2px solid #86efac;
}

.badge-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #b45309;
    border: 2px solid #fcd34d;
}

.badge-danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #b91c1c;
    border: 2px solid #fca5a5;
}

.badge-info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border: 2px solid #93c5fd;
}
    background: #dbeafe;
    color: #1e40af;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit {
    background: #dbeafe;
    color: #1e40af;
}

.btn-edit:hover {
    background: #3b82f6;
    color: white;
}

.btn-delete {
    background: #fee2e2;
    color: #b91c1c;
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ── Mobile Admin Top Bar ─────────────────────────────────── */
.admin-mobile-bar {
    display: none;
}

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.admin-overlay.active {
    display: block;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .login-container {
        grid-template-columns: 1fr;
    }

    .login-info {
        display: none;
    }

    /* Show mobile topbar */
    .admin-mobile-bar {
        display: flex;
        align-items: center;
        gap: .75rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: #1e293b;
        color: #fff;
        padding: 0 1rem;
        z-index: 1001;
        box-shadow: 0 2px 12px rgba(0,0,0,.35);
    }

    .admin-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,.1);
        border: none;
        border-radius: 8px;
        color: #fff;
        cursor: pointer;
        transition: background .2s;
        flex-shrink: 0;
    }
    .admin-menu-btn:hover {
        background: rgba(255,255,255,.2);
    }

    .admin-mobile-title {
        font-size: .95rem;
        font-weight: 700;
        color: #fff;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .admin-mobile-user {
        font-size: .78rem;
        color: #94a3b8;
        white-space: nowrap;
    }

    /* Layout collapses, sidebar becomes drawer */
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed;
        top: 56px;               /* below mobile topbar */
        left: -280px;
        width: 280px;            /* explicit width required for fixed positioning */
        height: calc(100vh - 56px);
        transition: left .3s ease;
        z-index: 1000;
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(0,0,0,.35);
    }

    .admin-sidebar.active {
        left: 0;
    }

    .admin-main {
        width: 100%;
        min-width: 0;            /* prevent grid blowout */
        padding-top: calc(56px + 1.5rem);  /* offset for topbar */
    }
}

@media (max-width: 768px) {
    .login-card {
        padding: 2rem 1.5rem;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .admin-user {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    /* Prevent tables from breaking layout */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td {
        padding: .65rem .75rem;
        font-size: .82rem;
        white-space: nowrap;
    }

    .admin-main {
        padding: calc(56px + 1rem) .75rem .75rem;
    }

    .modal-content {
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 95vh;
    }

    .modal {
        padding: 0;
        align-items: flex-end;
    }
}

@media (max-width: 480px) {
    .action-buttons {
        flex-wrap: wrap;
    }

    .admin-title {
        font-size: 1.3rem;
    }
}

/* Búsqueda rápida — lista de productos (admin) */
.productos-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.25rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    background: linear-gradient(145deg, #f8fafc 0%, #eef2ff 55%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.productos-quick-search-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 220px;
    max-width: 480px;
}

.productos-quick-search-heading {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6366f1;
}

.productos-quick-search-field {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem 0.55rem 0.85rem;
    background: #fff;
    border: 2px solid #c7d2fe;
    border-radius: 9999px;
    box-shadow:
        0 2px 8px rgba(99, 102, 241, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.productos-quick-search-field:focus-within {
    border-color: #6366f1;
    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.2),
        0 4px 14px rgba(99, 102, 241, 0.12);
}

.productos-quick-search-icon {
    flex-shrink: 0;
    color: #818cf8;
    opacity: 0.95;
}

.productos-quick-search-field:focus-within .productos-quick-search-icon {
    color: #4f46e5;
}

.productos-quick-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
    padding: 0.2rem 0.25rem 0.2rem 0;
}

.productos-quick-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.productos-quick-search-input:focus {
    outline: none;
}

/* Quitar estilo nativo del type=search en WebKit */
.productos-quick-search-input::-webkit-search-decoration,
.productos-quick-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.productos-filter-meta {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
    flex: 1 1 auto;
    min-width: 140px;
    padding-bottom: 0.15rem;
}
