/**
 * freeviddown - Admin Panel Styles
 */

/* ============================================
   Admin Layout
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
}

.nav-icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: block;
    }
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.admin-main {
    margin-left: 250px;
    min-height: 100vh;
    background: var(--bg-primary);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ============================================
   Pages
   ============================================ */
.page {
    display: none;
    padding: 2rem;
}

.page.active {
    display: block;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
}

/* ============================================
   Tables
   ============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: var(--bg-tertiary);
}

.table td:last-child {
    white-space: nowrap;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
}

.badge-pending {
    background: var(--warning-color);
    color: #000;
}

.badge-processing {
    background: var(--primary-color);
    color: #fff;
}

.badge-completed {
    background: var(--success-color);
    color: #fff;
}

.badge-failed {
    background: var(--error-color);
    color: #fff;
}

.badge-success {
    background: var(--success-color);
    color: #fff;
}

.badge-danger {
    background: var(--error-color);
    color: #fff;
}

.badge-warning {
    background: var(--warning-color);
    color: #000;
}

/* ============================================
   Toggle Switch
   ============================================ */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle input:checked+.toggle-slider {
    background-color: var(--primary-color);
}

.toggle input:checked+.toggle-slider:before {
    transform: translateX(24px);
}

/* ============================================
   Buttons
   ============================================ */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.pagination button:hover {
    background: var(--bg-tertiary);
}

.pagination button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ============================================
   RTL Support
   ============================================ */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

[dir="rtl"] .admin-main {
    margin-left: 0;
    margin-right: 250px;
}

[dir="rtl"] .nav-icon {
    margin-left: 0.75rem;
    margin-right: 0;
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    .admin-main {
        margin-left: 200px;
    }

    [dir="rtl"] .admin-main {
        margin-left: 0;
        margin-right: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 250px;
        z-index: 1000;
        transition: transform 0.3s;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
        right: 0;
        left: auto;
    }

    [dir="rtl"] .sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100%;
    }

    .admin-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 90;
    }

    .page {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-color);
    }

    .table {
        min-width: 600px;
        /* Force scroll */
        font-size: 0.875rem;
        margin-bottom: 0;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }

    .card {
        padding: 1rem;
    }

    /* Overlay for sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 900;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   Toast override for admin
   ============================================ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ============================================
   Enhanced Downloads Table Styles
   ============================================ */
.url-cell {
    max-width: 300px;
    word-break: break-all;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.visitor-info {
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 150px;
}

.visitor-ip {
    color: var(--primary-color);
    font-weight: 600;
}

.visitor-ua {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.7rem;
}

/* ============================================
   Dashboard Charts
   ============================================ */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-card {
    position: relative;
    height: 300px;
}

.chart-card canvas {
    max-height: 250px !important;
    width: 100% !important;
}

.analytics-list {
    max-height: 250px;
    overflow-y: auto;
}

.analytics-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.analytics-item:last-child {
    border-bottom: none;
}

.analytics-item-label {
    color: var(--text-secondary);
}

.analytics-item-value {
    font-weight: 600;
    color: var(--text-primary);
}

.list-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

@media (max-width: 1024px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Large Modal & Tabs
   ============================================ */
.modal-large {
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-body {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    padding: 2rem;
}

/* Enhanced Tab Navigation */
.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
    gap: 1rem;
}

.tab-btn {
    padding: 1rem 1.5rem;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Content Fade In */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

/* Better Input Styling for Modal */
.modal-large .input {
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.modal-large label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.modal-large textarea {
    line-height: 1.5;
    font-family: inherit;
}

/* Grid Layouts for Tabs */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Theme Toggle Icons
   ============================================ */
.theme-dark .icon-moon {
    display: none;
}

.theme-dark .icon-sun {
    display: inline;
}

.theme-light .icon-moon {
    display: inline;
}

.theme-light .icon-sun {
    display: none;
}

#themeToggle {
    font-size: 1.25rem;
    cursor: pointer;
}