/* ============================================================
   SkillsCom — Design System (Tailwind-compatible)
   https://tailwindcss.com style
   ============================================================ */

/* === Design Tokens === */
:root {
    /* Primary palette — Indigo / Violet */
    --color-primary:       #6366f1;
    --color-primary-dark:  #4f46e5;
    --color-primary-light: #818cf8;
    --color-primary-glow:  rgba(99,102,241,0.18);
    --color-accent:        #8b5cf6;
    --color-accent-light:  #a78bfa;

    /* Semantic */
    --color-success:       #34d399;
    --color-warning:       #fbbf24;
    --color-danger:        #f87171;
    --color-info:          #60a5fa;

    /* Backgrounds */
    --bg-primary:    #f8fafc;
    --bg-secondary:  #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f1f5f9;
    --bg-hover:      #eef2ff;
    --bg-disabled:   #e2e8f0;

    /* Text */
    --text-primary:    #0f172a;
    --text-secondary:  #475569;
    --text-tertiary:   #94a3b8;
    --text-inverse:    #ffffff;

    /* Borders */
    --border-card:    #e2e8f0;
    --border-strong:  #cbd5e1;
    --border-input:   #cbd5e1;

    /* Shadows */
    --shadow-sm:   0 1px 2px  rgba(15,23,42,0.04);
    --shadow-card: 0 2px 12px rgba(15,23,42,0.04);
    --shadow-md:   0 4px 24px rgba(15,23,42,0.08);
    --shadow-lg:   0 12px 48px rgba(15,23,42,0.12);

    /* Radius */
    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  16px;
    --radius-xl:  20px;

    /* Typography */
    --font-family: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono:   'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* Layout */
    --topnav-height: 60px;
    --footer-height: 36px;
    --sidebar-width: 240px;
    --content-max-width: 1520px;
}

/* === Tailwind Preflight Override (safe base) === */
*, ::before, ::after {
    box-sizing: border-box;
}
html {
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
}
body {
    margin: 0;
    font-family: var(--font-family);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}
img, svg { display: block; max-width: 100%; }
h1,h2,h3,h4,h5,h6 { margin: 0; font-weight: 600; line-height: 1.3; }

/* ============================================================
   TOP NAVIGATION BAR
   ============================================================ */
.admin-topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topnav-height);
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-card);
    z-index: 100;
    padding: 0;
}

.admin-topnav-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 32px;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.topnav-brand:hover {
    opacity: 0.85;
}

.topnav-logo {
    height: 32px;
    width: auto;
    flex-shrink: 0;
}

/* Gradient SkillsCom brand text */
.topnav-brand-text {
    font-size: 18px;
    font-weight: 900;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 40%, #a855f7 70%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
    letter-spacing: -0.3px;
}

.topnav-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Navigation links */
.topnav-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}
.topnav-link:hover {
    background: var(--bg-hover);
    color: var(--color-primary);
}
.topnav-link.active {
    background: var(--color-primary-glow);
    color: var(--color-primary);
    font-weight: 600;
}

/* Right section */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topnav-tech-support {
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
}
.topnav-tech-support:hover {
    color: var(--color-primary);
}

/* User avatar — colorful gradient */
.user-avatar-wrapper {
    position: relative;
}
.user-avatar {
    width: auto;
    min-width: 38px;
    height: 34px;
    border-radius: 17px;
    padding: 0 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
    user-select: none;
    letter-spacing: 0;
    white-space: nowrap;
}
.user-avatar:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(99,102,241,0.5);
}
/* User dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: #ffffff;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
    z-index: 200;
    overflow: hidden;
}
.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-card);
}
.dropdown-username {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.dropdown-role {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--color-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-card);
    margin: 4px 0;
}

.dropdown-logout {
    color: var(--color-danger) !important;
}
.dropdown-logout:hover {
    background: rgba(248,113,113,0.08) !important;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.admin-main {
    flex: 1;
    padding-top: calc(var(--topnav-height) + 24px);
    padding-bottom: calc(var(--footer-height) + 24px);
    padding-left: 0;
    padding-right: 0;
    min-height: 0;
}

.admin-main-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 32px;
}

/* Page title — align with content inner */
.admin-main > .page-title {
    max-width: var(--content-max-width);
    margin: 0 auto 24px;
    padding: 0 32px;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

/* ============================================================
   FOOTER (minimal)
   ============================================================ */
.admin-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--footer-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-card);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 24px;
    z-index: 50;
    font-size: 11px;
    color: var(--text-tertiary);
}
.footer-divider {
    color: var(--border-card);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s, border-color 0.2s;
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.card-stat {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}
.card-stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    border: none;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-card);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary-light);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border: none;
}
.btn-danger:hover {
    background: #ef4444;
    box-shadow: 0 4px 14px rgba(248,113,113,0.3);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
    border: none;
}
.btn-success:hover {
    background: #10b981;
    box-shadow: 0 4px 14px rgba(52,211,153,0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-card);
}
.btn-ghost:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 11px;
    border-radius: 5px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 4px;
}

.btn-icon {
    padding: 6px 8px;
    min-width: unset;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* ============================================================
   FORM INPUTS
   ============================================================ */
.input-field {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.2s;
}
.input-field:hover {
    border-color: var(--border-strong);
}
.input-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
    background: var(--bg-secondary);
}
.input-field::placeholder {
    color: var(--text-tertiary);
}

select.input-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 36px;
}

/* ============================================================
   TABLES
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-card);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-card);
    color: var(--text-primary);
}
.data-table tbody tr {
    transition: background 0.15s;
}
.data-table tbody tr:hover {
    background: var(--bg-hover);
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-primary {
    background: var(--color-primary-glow);
    color: var(--color-primary);
}
.badge-success {
    background: rgba(52,211,153,0.12);
    color: var(--color-success);
}
.badge-warning {
    background: rgba(251,191,36,0.12);
    color: #d97706;
}
.badge-danger {
    background: rgba(248,113,113,0.12);
    color: var(--color-danger);
}
.badge-info {
    background: rgba(96,165,250,0.12);
    color: var(--color-info);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: calc(var(--topnav-height) + 16px);
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: #ffffff;
    border: 1px solid var(--border-card);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastSlideIn 0.35s ease;
    max-width: 380px;
}
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error   { border-left: 3px solid var(--color-danger); }
.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.info    { border-left: 3px solid var(--color-info); }
.toast.fade-out {
    animation: toastSlideOut 0.3s ease forwards;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: modalFadeIn 0.2s ease;
}
.modal-overlay.hidden {
    display: none;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    animation: modalSlideIn 0.25s ease;
    overflow: hidden;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--bg-input);
    color: var(--text-tertiary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.modal-close:hover {
    background: rgba(248,113,113,0.12);
    color: var(--color-danger);
}

.modal-body {
    padding: 16px 24px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 20px;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}
.pagination button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border-card);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pagination button:hover {
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}
.pagination button.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    color: #fff;
    border-color: transparent;
}
.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-card);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab:hover {
    color: var(--text-secondary);
}
.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center    { text-align: center; }
.text-right     { text-align: right; }
.text-muted     { color: var(--text-tertiary) !important; }
.text-primary   { color: var(--color-primary) !important; }
.text-danger    { color: var(--color-danger) !important; }
.text-success   { color: var(--color-success) !important; }

.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.gap-4           { gap: 16px; }
.gap-6           { gap: 24px; }
.flex-1          { flex: 1 1 0%; }
.flex-wrap       { flex-wrap: wrap; }

.w-full   { width: 100%; }
.mt-2     { margin-top: 8px; }
.mt-4     { margin-top: 16px; }
.mt-6     { margin-top: 24px; }
.mb-2     { margin-bottom: 8px; }
.mb-4     { margin-bottom: 16px; }
.mb-6     { margin-bottom: 24px; }
.p-4      { padding: 16px; }
.p-6      { padding: 24px; }

.rounded-lg  { border-radius: var(--radius-lg); }
.shadow-sm   { box-shadow: var(--shadow-sm); }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .admin-topnav-inner {
        padding: 0 12px;
        gap: 8px;
    }
    .topnav-title {
        display: none;
    }
    .topnav-nav {
        gap: 0;
    }
    .topnav-link {
        padding: 6px 10px;
        font-size: 12px;
    }
    .topnav-tech-support {
        display: none;
    }
    .admin-main {
        padding-top: calc(var(--topnav-height) + 16px);
        padding-bottom: calc(var(--footer-height) + 16px);
    }
    .admin-main-inner {
        padding: 0 12px;
    }
    .admin-main > .page-title {
        padding: 0 12px;
    }
    .admin-footer {
        gap: 6px;
        font-size: 10px;
    }
    .footer-divider {
        display: none;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .toast {
        max-width: 300px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .topnav-logo {
        height: 26px;
    }
    .topnav-link {
        padding: 4px 8px;
        font-size: 11px;
    }
    .user-avatar {
        min-width: 28px;
        height: 28px;
        border-radius: 14px;
        padding: 0 10px;
        font-size: 11px;
    }
    .admin-footer {
        flex-direction: column;
        height: auto;
        padding: 8px 12px;
        gap: 2px;
    }
    .btn {
        padding: 7px 14px;
        font-size: 12px;
    }
}
