/* ═══════════════════════════════════════════════════════════════════
   SnipLink — Admin Panel Premium Purple & White
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --bg-body:        #F8F7FC;
    --bg-white:       #FFFFFF;
    --bg-light:       #F3F0FF;
    --bg-purple-soft: #EDE9FE;

    --purple-50:  #FAF5FF;
    --purple-100: #F3E8FF;
    --purple-200: #E9D5FF;
    --purple-300: #D8B4FE;
    --purple-400: #C084FC;
    --purple-500: #A855F7;
    --purple-600: #9333EA;
    --purple-700: #7C3AED;
    --purple-800: #6C2BD9;
    --purple-900: #581C87;

    --text-dark:    #1A1235;
    --text-body:    #4A4458;
    --text-muted:   #8E8BA0;
    --text-light:   #B4B0C7;

    --border:       #E8E4F0;
    --border-focus: var(--purple-400);

    --accent-green:  #10B981;
    --accent-red:    #EF4444;
    --accent-yellow: #F59E0B;
    --accent-blue:   #3B82F6;

    --gradient: linear-gradient(135deg, var(--purple-600) 0%, var(--purple-500) 50%, #C084FC 100%);

    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-xl:  24px;

    --shadow-sm:  0 1px 4px rgba(109,40,217,0.05);
    --shadow-md:  0 4px 16px rgba(109,40,217,0.07);
    --shadow-lg:  0 8px 32px rgba(109,40,217,0.10);

    --transition-fast: 0.15s cubic-bezier(0.4,0,0.2,1);
    --transition-med:  0.25s cubic-bezier(0.4,0,0.2,1);

    --sidebar-width: 270px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-body);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--purple-600); text-decoration: none; }
a:hover { color: var(--purple-800); }

/* ─── Admin Layout ────────────────────────────────────────────────── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1.5rem;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border);
}

.sidebar__brand-icon {
    width: 42px; height: 42px;
    min-width: 42px;
    background: var(--gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(147,51,234,0.3);
}

.sidebar__brand-icon svg {
    width: 22px; height: 22px;
    color: #fff;
}

.sidebar__section-label {
    padding: 1.25rem 1.5rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.sidebar__nav {
    flex: 1;
    padding: 0.5rem 0;
    list-style: none;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.5rem;
    margin: 0.15rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.sidebar__link svg {
    width: 20px; height: 20px;
    min-width: 20px;
    stroke-width: 1.8;
}

.sidebar__link:hover {
    background: var(--bg-light);
    color: var(--purple-700);
}

.sidebar__link.active {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(147,51,234,0.25);
}

.sidebar__link.active svg { color: #fff; }

.sidebar__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.sidebar__avatar {
    width: 40px; height: 40px;
    background: var(--gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: #fff;
}

.sidebar__user-info {}
.sidebar__user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
}

.sidebar__user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius-md);
    color: var(--accent-red);
    font-size: 0.8rem;
    font-weight: 600;
    width: 100%;
    transition: all var(--transition-fast);
}

.sidebar__logout svg { width: 16px; height: 16px; }
.sidebar__logout:hover { background: #FEE2E2; color: var(--accent-red); }

/* ─── Main Content ────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.main-header__title {
    font-size: 1.75rem;
    font-weight: 900;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

.main-header__subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ─── Stat Cards ──────────────────────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    transition: all var(--transition-med);
    position: relative;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--purple-200);
}

.stat-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.stat-card__icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card__icon svg { width: 24px; height: 24px; }

.stat-card--purple .stat-card__icon { background: var(--purple-100); color: var(--purple-600); }
.stat-card--green  .stat-card__icon { background: #D1FAE5; color: var(--accent-green); }
.stat-card--yellow .stat-card__icon { background: #FEF3C7; color: var(--accent-yellow); }
.stat-card--blue   .stat-card__icon { background: #DBEAFE; color: var(--accent-blue); }

.stat-card__value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-dark);
    letter-spacing: -1px;
}

.stat-card__label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-weight: 600;
}

/* ─── Glass Panel ─────────────────────────────────────────────────── */
.glass-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.glass-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.glass-panel__title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glass-panel__title svg { width: 20px; height: 20px; color: var(--purple-500); }

/* ─── Data Table ──────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-body);
}

.data-table th:first-child { border-radius: var(--radius-md) 0 0 0; }
.data-table th:last-child  { border-radius: 0 var(--radius-md) 0 0; }

.data-table td {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--purple-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table .url-cell {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table .code-cell {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--purple-700);
    font-weight: 700;
    font-size: 0.85rem;
}

/* ─── Short URL Pill ─────────────────────────────────────────────── */
.short-url-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--purple-50);
    border: 1px solid var(--purple-200);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-md);
    max-width: 320px;
}

.short-url-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--purple-700);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.short-url-text:hover { color: var(--purple-900); }

.copy-mini-btn {
    background: #FFFFFF;
    border: 1px solid var(--purple-200);
    color: var(--purple-600);
    cursor: pointer;
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.copy-mini-btn:hover {
    background: var(--purple-600);
    border-color: var(--purple-600);
    color: #FFFFFF;
}

.copy-mini-btn svg { width: 13px; height: 13px; }

/* ─── Badge ───────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.badge--active {
    background: #D1FAE5;
    color: #065F46;
}

.badge--inactive {
    background: #FEE2E2;
    color: #991B1B;
}

.badge--masked {
    background: var(--purple-100);
    color: var(--purple-800);
    border: 1px solid var(--purple-200);
}

.badge--direct {
    background: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

.badge--dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge--active .badge--dot { background: var(--accent-green); }
.badge--inactive .badge--dot { background: var(--accent-red); }
.badge--masked .badge--dot { background: var(--purple-600); }
.badge--direct .badge--dot { background: #3B82F6; }

/* ─── Toggle Switch ───────────────────────────────────────────────── */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    user-select: none;
    margin-top: 0.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border);
    transition: var(--transition-fast);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

input:checked + .slider {
    background-color: var(--purple-600);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.switch-label-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-dark);
}

.switch-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    margin-top: 0.2rem;
}

/* ─── Action Buttons ──────────────────────────────────────────────── */
.actions {
    display: flex;
    gap: 0.35rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(147,51,234,0.3);
}

.btn--primary:hover {
    box-shadow: 0 6px 20px rgba(147,51,234,0.4);
    transform: translateY(-1px);
}

.btn--secondary {
    background: var(--bg-light);
    color: var(--purple-700);
    border: 1px solid var(--purple-200);
}

.btn--secondary:hover { background: var(--purple-100); }

.btn--danger {
    background: #FEF2F2;
    color: var(--accent-red);
    border: 1px solid #FECACA;
}

.btn--danger:hover { background: #FEE2E2; }

.btn--success {
    background: #ECFDF5;
    color: var(--accent-green);
    border: 1px solid #A7F3D0;
}

.btn--sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }

.btn--icon {
    padding: 0.5rem;
    min-width: 34px; min-height: 34px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn--icon:hover {
    background: var(--bg-light);
    color: var(--purple-600);
    border-color: var(--purple-200);
}

.btn--icon.btn--danger {
    background: #FEF2F2;
    color: var(--accent-red);
    border-color: #FECACA;
}

.btn--icon.btn--danger:hover { background: #FEE2E2; }

/* ─── Universal Inputs & Form Controls ────────────────────────────── */
.input {
    width: 100%;
    padding: 0.85rem 1.15rem;
    background: #FFFFFF;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-fast);
    box-sizing: border-box;
    display: block;
    line-height: 1.4;
}

.input::placeholder { color: var(--text-light); font-weight: 400; }

.input:focus {
    border-color: var(--purple-400);
    background: #FFFFFF;
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.12);
}

.input--no-icon {
    padding-left: 1.15rem !important;
}

.input-icon-wrapper {
    position: relative;
    width: 100%;
}

.input-icon-wrapper svg {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    width: 18px;
    height: 18px;
    pointer-events: none;
    transition: color var(--transition-fast);
    z-index: 2;
}

.input-icon-wrapper .input {
    padding-left: 3rem !important;
}

.input-icon-wrapper .input:focus + svg,
.input-icon-wrapper .input:focus ~ svg {
    color: var(--purple-600);
}

/* ─── Quick Shorten Bar ───────────────────────────────────────────── */
.quick-shorten-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.quick-shorten-url {
    flex: 3;
    min-width: 260px;
}

.quick-shorten-alias {
    flex: 2;
    min-width: 160px;
}

.quick-shorten-mask {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #FFFFFF;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.1rem;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--transition-fast);
}

.quick-shorten-mask:hover {
    border-color: var(--purple-300);
}

/* ─── Search Bar ──────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.search-wrapper svg {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    width: 18px;
    height: 18px;
    pointer-events: none;
    z-index: 2;
}

.search-wrapper .input {
    padding-left: 3rem;
}

/* ─── Pagination ──────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1.5rem;
}

.pagination__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.pagination__btn:hover {
    background: var(--bg-light);
    color: var(--purple-700);
    border-color: var(--purple-200);
}

.pagination__btn.active {
    background: var(--gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 3px 10px rgba(147,51,234,0.25);
}

.pagination__btn.disabled { opacity: 0.3; pointer-events: none; }

/* ─── Charts ──────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* ─── Forms ───────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.form-group .input {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg-body);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all var(--transition-fast);
}

.form-group .input:focus {
    border-color: var(--purple-400);
    box-shadow: 0 0 0 4px rgba(168,85,247,0.08);
    background: var(--bg-white);
}

.form-group small {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ─── Toast ───────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem; right: 2rem;
    padding: 0.85rem 1.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-dark);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-med);
    z-index: 9999;
}

.toast.active { transform: translateY(0); opacity: 1; }
.toast--error { border-color: #FECACA; color: var(--accent-red); }

/* ─── Empty State ─────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state__icon {
    width: 64px; height: 64px;
    margin: 0 auto 1rem;
    background: var(--purple-100);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.empty-state__text {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26,18,53,0.5);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal-overlay.active { display: flex; }

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease-out;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal__title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-dark);
}

.modal__close {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.3rem;
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal__close:hover { background: var(--bg-light); color: var(--text-dark); }

.modal__actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ─── Animations ──────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1rem; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .main-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .search-bar { flex-direction: column; }
    .search-wrapper { min-width: 100%; }
}
