/* =========================================================
   Phonopedia Admin Dashboard Styles
   ========================================================= */

body.admin-body {
    background-color: #f0f2f5;
    font-family: var(--font-body);
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────── */
.admin-sidebar {
    width: 280px;
    background: var(--dark);
    color: var(--white);
    flex-shrink: 0;
    transition: var(--transition);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.admin-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.logo-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-link .logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--white);
}

.logo-link .logo-text span {
    color: var(--red);
}

.admin-badge {
    background: var(--red);
    color: var(--white);
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--gray);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link i {
    width: 20px;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--red);
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 20px 0;
}

.exit-link {
    color: var(--red-light);
}

/* ─── Main Content ───────────────────────────────────── */
.admin-main {
    flex-grow: 1;
    overflow-x: hidden;
}

.admin-topbar {
    height: 70px;
    background: var(--white);
    border-bottom: 1px solid var(--mid-gray);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--blue);
    flex-grow: 1;
    margin-left: 15px;
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--off-white);
    border: none;
    border-radius: 10px;
    color: var(--blue);
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(18, 45, 107, 0.05);
}

.sidebar-toggle:hover {
    background: var(--blue);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(18, 45, 107, 0.15);
}

.sidebar-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: var(--white);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    position: absolute;
    left: 10px;
    top: 10px;
}

.sidebar-close:hover {
    background: var(--red);
    color: var(--white);
    transform: rotate(90deg);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    padding: 0;
}

.user-avatar:hover {
    background: var(--blue-dark);
    transform: scale(1.05);
}

.user-avatar::after {
    display: none;
}

.topbar-user .dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
    min-width: 180px;
    margin-top: 8px;
}

.topbar-user .dropdown-item {
    padding: 10px 16px;
    font-size: 14px;
    color: var(--dark);
    transition: var(--transition);
}

.topbar-user .dropdown-item:hover {
    background-color: var(--light-bg);
    color: var(--blue);
}

.topbar-user .dropdown-item.text-danger:hover {
    background-color: rgba(215, 57, 52, 0.1);
    color: var(--red);
}

.topbar-user .dropdown-divider {
    margin: 8px 0;
    border-color: var(--border-color);
}

.admin-content {
    padding: 30px;
}

/* ─── Cards & Dashboard ──────────────────────────────── */
.admin-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue {
    background: rgba(18, 45, 107, 0.1);
    color: var(--blue);
}

.stat-icon.red {
    background: rgba(215, 57, 52, 0.1);
    color: var(--red);
}

.stat-icon.green {
    background: rgba(0, 184, 148, 0.1);
    color: #00b894;
}

.stat-info h4 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.stat-info p {
    margin: 0;
    color: var(--gray);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* ─── Tables ─────────────────────────────────────────── */
.card-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid var(--mid-gray);
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(18, 45, 107, 0.05);
}

.filter-box select {
    padding: 10px 15px;
    border: 1px solid var(--mid-gray);
    border-radius: 8px;
    outline: none;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table th {
    background: #f8f9fb;
    padding: 15px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--mid-gray);
    text-transform: uppercase;
}

.admin-table td {
    padding: 15px;
    vertical-align: middle;
    border-bottom: 1px solid var(--mid-gray);
}

.admin-table tr:hover td {
    background: #fafbfc;
}

.table-thumb {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
}

.badge-pill {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.actions-cell {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: var(--transition);
}

.btn-icon.edit {
    background: rgba(18, 45, 107, 0.1);
    color: var(--blue);
}

.btn-icon.delete {
    background: rgba(215, 57, 52, 0.1);
    color: var(--red);
}

.btn-icon:hover {
    transform: scale(1.1);
}

/* ─── Form Elements ──────────────────────────────────── */
.badge-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border: 1px solid var(--mid-gray);
    padding: 12px;
    border-radius: 8px;
}

.camera-row {
    background: #f8f9fb;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.form-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--red);
    display: inline-block;
}

.spec-tab-section {
    border: 1px solid var(--mid-gray);
}

.gallery-preview-item {
    position: relative;
    border: 1px solid var(--mid-gray);
    padding: 2px;
    border-radius: 6px;
    background: var(--white);
    width: 70px;
    height: 70px;
}

.gallery-preview-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
}

.gallery-add-box {
    width: 70px;
    height: 70px;
    border: 2px dashed var(--mid-gray);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--soft-gray);
    cursor: pointer;
    transition: var(--transition);
}

.gallery-add-box:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: rgba(var(--blue-rgb), 0.05);
}

.thumb-preview-wrap {
    width: 100%;
    height: 180px;
    border: 1px solid var(--mid-gray);
    border-radius: 8px;
    background: #fdfdfd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 10px;
}

.thumb-preview-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.remove-gallery-img {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--red);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    z-index: 10;
}

.remove-gallery-img:hover {
    transform: scale(1.2);
    background: var(--red-dark);
}

/* ─── Profile Page Styles ────────────────────────────── */
.card-header {
    border-bottom: 1px solid var(--mid-gray);
    margin-bottom: 0;
    padding: 0 0 16px 0;
}

.card-header h3 {
    color: var(--blue);
    font-size: 1.3rem;
}

.card-header p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.card-body {
    padding: 24px 0;
}

.change-password-form .form-label {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.change-password-form .form-control {
    border: 2px solid var(--mid-gray);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 0.95rem;
    transition: var(--transition);
}

.change-password-form .form-control:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(215, 57, 52, 0.1);
    outline: none;
}

.change-password-form .input-group {
    display: flex;
    align-items: center;
    gap: 0;
}

.change-password-form .input-group .form-control {
    flex: 1;
    border-radius: var(--radius) 0 0 var(--radius);
    margin: 0;
}

.change-password-form .input-group .btn {
    border: 2px solid var(--mid-gray);
    border-left: 1px solid var(--mid-gray);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 10px 12px;
    height: auto;
    min-width: auto;
    color: var(--gray);
    background: var(--off-white);
    transition: var(--transition);
}

.change-password-form .input-group .btn:hover {
    background: var(--light-gray);
    color: var(--red);
    border-color: var(--red);
}

.change-password-form .input-group .form-control:focus+.btn {
    border-color: var(--red);
}

.change-password-form .form-text {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 4px;
}

.change-password-form .btn-primary {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    border: none;
    color: var(--white);
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius);
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(215, 57, 52, 0.25);
}

.change-password-form .btn-primary:hover {
    background: linear-gradient(135deg, var(--red-dark), var(--red));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(215, 57, 52, 0.35);
}

.change-password-form .btn-primary:active {
    transform: translateY(0);
}

.change-password-form .btn-secondary {
    border: 2px solid var(--mid-gray);
    color: var(--dark);
    background: var(--white);
    font-weight: 600;
    padding: 10px 24px;
    transition: var(--transition);
}

.change-password-form .btn-secondary:hover {
    background: var(--light-gray);
    border-color: var(--dark-gray);
}

/* ─── Mobile Responsiveness ──────────────────────────── */
@media (max-width: 991px) {
    .admin-sidebar {
        position: fixed;
        left: -280px;
        box-shadow: 15px 0 30px rgba(0, 0, 0, 0.1);
    }

    .admin-sidebar.active {
        left: 0;
    }

    .admin-main {
        width: 100%;
    }

    .admin-topbar {
        padding: 0 20px;
    }

    .topbar-title {
        font-size: 1.1rem;
        margin-left: 10px;
    }
}

.loading-relative {
    position: relative;
    min-height: 200px;
}

.admin-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
    border-radius: var(--radius);
    animation: fadeIn 0.3s ease;
}

.spinner-custom {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(18, 45, 107, 0.1);
    border-top: 4px solid var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* ─── Toast Notifications ────────────────────────────── */
.admin-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.admin-toast {
    min-width: 300px;
    padding: 12px 20px;
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--dark);
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-left: 4px solid var(--blue);
}

@keyframes toastIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.admin-toast.success { border-left-color: #2ecc71; }
.admin-toast.error { border-left-color: var(--red); }
.admin-toast.info { border-left-color: var(--blue); }

.admin-toast i {
    font-size: 1.1rem;
}

.admin-toast.success i { color: #2ecc71; }
.admin-toast.error i { color: var(--red); }
.admin-toast.info i { color: var(--blue); }

.toast-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(18, 45, 107, 0.1);
    border-top: 2px solid var(--blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.admin-toast.exit {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { transform: translateY(-20px); opacity: 0; }
}

.drag-handle {
    cursor: grab;
    width: 30px;
    text-align: center;
}

.drag-handle:active {
    cursor: grabbing;
}

tr.dragging {
    opacity: 0.5;
    background: #f0f2f5 !important;
}

.news-row, .banner-row {
    transition: background 0.2s ease;
}

.news-row:hover, .banner-row:hover {
    background: #fafbfc;
}

/* ─── Pagination & Quick Actions ───────────────────────── */
.admin-pagination input[type="number"]::-webkit-inner-spin-button, 
.admin-pagination input[type="number"]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

.quick-actions-bar {
    background-color: #fff9e6 !important; /* Subtle highlight */
    border-top: 1px solid var(--border-color);
}

.quick-actions-bar .vr {
    height: 24px;
    background-color: var(--border-color);
    width: 1px;
}

.product-select-cb {
    cursor: pointer;
    width: 1.2rem;
    height: 1.2rem;
}