/**
 * My Network Tools - Admin & Client Dashboard Styles
 * Works alongside Bootstrap 5.3.3 — does NOT override Bootstrap classes
 */

/* ========================================
   Accessibility
   ======================================== */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 10000;
    padding: 12px 24px;
    background: var(--accent, #0d6efd);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    transition: top 0.2s ease;
}
.skip-to-content:focus {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
:focus-visible {
    outline: 3px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1a1a2e;
    --sidebar-dark: #151f2b;
    --topbar-height: 56px;
    --accent: #0d6efd;
    --accent-hover: #0b5ed7;
}

/* ========================================
   Base (Bootstrap companion)
   ======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f8f9fa;
    color: #212529;
    line-height: 1.6;
}

a { text-decoration: none; }

/* ========================================
   Admin Layout: Topbar + Sidebar + Main
   ======================================== */

/* Top Bar */
.admin-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1040;
}
.admin-topbar-left { display: flex; align-items: center; gap: 12px; }
.admin-topbar-brand { color: #fff; font-size: 1.1rem; font-weight: 600; text-decoration: none; }
.admin-topbar-brand:hover { color: #93c5fd; }
.admin-topbar-badge { background: var(--accent); color: #fff; font-size: 0.7rem; padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.admin-topbar-right { display: flex; align-items: center; gap: 15px; }
.admin-topbar-user { display: flex; align-items: center; gap: 8px; }
.admin-topbar-initials { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.admin-topbar-name { color: #94a3b8; font-size: 0.85rem; }
.admin-topbar-logout { color: #f87171; text-decoration: none; font-size: 0.8rem; padding: 4px 12px; border: 1px solid #f87171; border-radius: 6px; transition: all 0.2s; }
.admin-topbar-logout:hover { background: #f87171; color: #fff; }

/* Sidebar */
.admin-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    overflow: hidden;
}
.admin-sidebar.has-topbar { top: var(--topbar-height); height: calc(100vh - var(--topbar-height)); }

.admin-sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.admin-sidebar-nav::-webkit-scrollbar { width: 5px; }
.admin-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.admin-sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #94a3b8; font-size: 0.88rem;
    transition: all 0.15s; text-decoration: none;
}
.admin-sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.05); }
.admin-sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); border-right: 3px solid var(--accent); }
.admin-sidebar-icon { font-size: 1.1rem; width: 22px; text-align: center; }

/* Sidebar groups */
.admin-sidebar-group-toggle {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #94a3b8; font-size: 0.88rem;
    cursor: pointer; transition: all 0.15s; user-select: none;
}
.admin-sidebar-group-toggle:hover { color: #fff; background: rgba(255,255,255,0.05); }
.admin-sidebar-chevron { margin-left: auto; font-size: 0.7rem; transition: transform 0.2s; }
.admin-sidebar-group.open .admin-sidebar-chevron { transform: rotate(90deg); }
.admin-sidebar-submenu { display: none; padding: 2px 0; }
.admin-sidebar-group.open .admin-sidebar-submenu { display: block; }
.admin-sidebar-submenu a {
    display: block; padding: 7px 20px 7px 52px; color: #64748b; font-size: 0.82rem;
    text-decoration: none; transition: all 0.15s;
}
.admin-sidebar-submenu a:hover { color: #fff; background: rgba(255,255,255,0.03); }
.admin-sidebar-submenu a.active { color: #93c5fd; }

/* Main wrapper */
.admin-wrapper { padding-top: var(--topbar-height); min-height: 100vh; }
.admin-main {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
}

/* ========================================
   Client Layout: Sidebar + Main
   ======================================== */
.client-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    overflow: hidden;
}

.sidebar-brand { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h1 { color: #fff; font-size: 1.2rem; font-weight: 600; margin: 0; }

.sidebar-user { padding: 16px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-user-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.sidebar-user-initials { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1.1rem; }
.sidebar-user-name { color: #e2e8f0; font-size: 0.9rem; font-weight: 500; }

.sidebar-site-switcher { padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.site-switcher-select { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.15); color: #e2e8f0; font-size: 0.82rem; }
.site-switcher-select option { background: #1a1a2e; color: #fff; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #94a3b8; font-size: 0.88rem;
    transition: all 0.15s; text-decoration: none;
}
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar-link.active { color: #fff; background: rgba(255,255,255,0.1); border-right: 3px solid var(--accent); }
.sidebar-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-badge { background: #ef4444; color: #fff; font-size: 0.65rem; padding: 2px 7px; border-radius: 10px; margin-left: auto; }

.sidebar-bottom { padding: 12px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-top: auto; }

.client-wrapper { min-height: 100vh; }
.client-main {
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
    background: #f8f9fa;
}

/* ========================================
   Mobile Header & Nav (Admin + Client)
   ======================================== */
.admin-mobile-header,
.client-mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: #fff;
    padding: 12px 20px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.admin-mobile-header h1,
.client-mobile-header h1 { font-size: 1.1rem; font-weight: 600; margin: 0; color: #333; }

.menu-toggle {
    width: 32px; height: 24px; display: flex; flex-direction: column; justify-content: space-between;
    border: none; background: none; cursor: pointer; padding: 0;
}
.menu-toggle span { display: block; height: 2px; background: #333; border-radius: 2px; transition: all 0.3s; }
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(6px, -6px); }

.mobile-nav-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1040; opacity: 0; transition: opacity 0.3s;
}
.mobile-nav-overlay.active { display: block; opacity: 1; }

.mobile-nav {
    position: fixed; top: 0; right: -300px; width: 280px; height: 100vh;
    background: #fff; z-index: 1050; transition: right 0.3s; overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}
.mobile-nav.active { right: 0; }
.mobile-nav-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.mobile-nav-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #666; padding: 0; line-height: 1; }
.mobile-nav-user { padding: 12px 20px; font-size: 0.9rem; color: #666; border-bottom: 1px solid #e5e7eb; }

.mobile-nav ul { list-style: none; padding: 8px 0; margin: 0; }
.mobile-nav ul li a { display: block; padding: 10px 20px; color: #333; font-size: 0.9rem; transition: background 0.15s; text-decoration: none; }
.mobile-nav ul li a:hover, .mobile-nav ul li a.active { background: #f0f0f0; color: var(--accent); }

.nav-dropdown-title { padding: 10px 20px; color: #333; font-size: 0.9rem; cursor: pointer; font-weight: 500; display: flex; justify-content: space-between; }
.nav-dropdown-title::after { content: '+'; color: #999; }
.nav-dropdown-title.active::after { content: '-'; }
.nav-dropdown-menu { display: none; }
.nav-dropdown-menu.active { display: block; }
.nav-dropdown-menu a { display: block; padding: 8px 20px 8px 36px; color: #555; font-size: 0.85rem; text-decoration: none; }
.nav-dropdown-menu a:hover { background: #f0f0f0; }

@media (max-width: 1024px) {
    .admin-topbar { display: none; }
    .admin-sidebar { display: none !important; }
    .admin-wrapper { padding-top: 0; }
    .admin-main { margin-left: 0; padding: 16px; }
    .admin-mobile-header { display: flex; }

    .client-sidebar { display: none !important; }
    .client-main { margin-left: 0; padding: 16px; }
    .client-mobile-header { display: flex; }

    .page-header h2 { font-size: 1.25rem; }
}

@media (max-width: 768px) {
    .admin-main, .client-main { padding: 12px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .header-actions { width: 100%; }
    .header-actions .btn { flex: 1; text-align: center; }

    /* Welcome card — stack left/right on mobile */
    .welcome-card { flex-direction: column !important; }
    .welcome-card-left { width: 100% !important; min-width: unset !important; padding: 20px !important; }
    .welcome-card-right { padding: 16px !important; }
    .welcome-card-stats { grid-template-columns: repeat(3, 1fr) !important; }

    /* File browser mobile */
    .file-date { display: none; }
    .file-size { min-width: 50px; font-size: 0.75rem; }
    .file-item { padding: 8px 12px; gap: 8px; }
    .file-name { font-size: 0.82rem; }
    .file-actions .btn { padding: 2px 6px; font-size: 0.7rem; }

    /* Tables — horizontal scroll */
    .table-responsive-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 500px; }
    .table th, .table td { font-size: 0.8rem; padding: 8px 6px; }

    /* Cards */
    .card-header { padding: 10px 14px; font-size: 0.9rem; }
    .card-body { padding: 14px; }
}

@media (max-width: 480px) {
    .admin-main, .client-main { padding: 8px; }
    .welcome-card-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .login-box { padding: 24px 20px; }
    .login-box h1 { font-size: 1.25rem; }
}

/* ========================================
   Page Header
   ======================================== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { margin: 0; font-size: 1.5rem; font-weight: 600; color: #212529; }
.header-actions { display: flex; gap: 8px; }

/* ========================================
   Custom Badge Variants (non-Bootstrap)
   ======================================== */
.badge-sm { font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; font-weight: 500; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* ========================================
   Custom Button Variants
   ======================================== */
.btn-xs { padding: 4px 10px; font-size: 0.75rem; }

/* ========================================
   Table Enhancements (extend Bootstrap)
   ======================================== */
.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 600;
    border-bottom-width: 1px;
}
.table td { vertical-align: middle; }
.table { font-size: 0.88rem; }

/* ========================================
   Stat Cards
   ======================================== */
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 14px 10px; }
    .stat-card .stat-number, .stat-card .num { font-size: 1.2rem; }
}
.stat-card { text-align: center; padding: 20px 16px; background: #fff; border-radius: 8px; border: 1px solid #e9ecef; }
.stat-card .stat-number, .stat-card .num { font-size: 1.5rem; font-weight: 700; color: #212529; }
.stat-card .stat-label, .stat-card .label { font-size: 0.7rem; color: #6c757d; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.stat-card.stat-success .stat-number { color: #198754; }
.stat-card.stat-warning .stat-number { color: #fd7e14; }
.stat-card.stat-danger .stat-number { color: #dc3545; }

/* ========================================
   Login Page
   ======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.login-box h1 { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 8px; }
.login-box .subtitle { text-align: center; color: #6c757d; margin-bottom: 24px; font-size: 0.9rem; }
.login-footer { text-align: center; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e9ecef; }
.login-footer a { color: #6c757d; font-size: 0.85rem; }
.login-footer a:hover { color: var(--accent); }

/* ========================================
   Card Enhancements (extend Bootstrap .card)
   ======================================== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    border-radius: 12px 12px 0 0 !important;
}

/* ========================================
   Form Enhancements
   ======================================== */
.form-label { font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }

/* ========================================
   Flash Messages
   ======================================== */
.flash-message { animation: fadeIn 0.3s ease-out; }

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

/* ========================================
   File Browser
   ======================================== */
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.file-item:hover { background: #f8f9fa; }
.file-icon { font-size: 1.2rem; width: 24px; text-align: center; }
.file-name { flex: 1; font-size: 0.88rem; color: #333; }
.file-name a { color: inherit; text-decoration: none; }
.file-name a:hover { color: var(--accent); }
.file-size { font-size: 0.8rem; color: #888; min-width: 70px; text-align: right; }
.file-date { font-size: 0.8rem; color: #888; min-width: 120px; text-align: right; }
.file-actions { display: flex; gap: 6px; }

/* ========================================
   Utility
   ======================================== */
.text-mono { font-family: 'SF Mono', Consolas, 'Courier New', monospace; }
.no-wrap { white-space: nowrap; }

/* ========================================
   Print
   ======================================== */
@media print {
    .admin-topbar, .admin-sidebar, .admin-mobile-header,
    .client-sidebar, .client-mobile-header { display: none !important; }
    .admin-main, .client-main { margin-left: 0 !important; padding: 0 !important; }
}
