/* =============================================
   IRM-HUB Finisher - Admin Styles (Metrix Light)
   ============================================= */

:root {
    --primary: #5570F1;
    --primary-light: #E8EBF9;
    --primary-glow: rgba(85, 112, 241, 0.10);
    --bg-body: #F4F5FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-input: #F4F5FA;
    --bg-topbar: rgba(255, 255, 255, 0.92);
    --border: #E1E2E9;
    --border-hover: #C8CAD4;
    --text-primary: #1C1D22;
    --text-secondary: #6E7079;
    --text-muted: #ABAFB1;
    --success: #519C66;
    --success-bg: #E7F7EF;
    --error: #CC5F5F;
    --error-bg: #FCEAEA;
    --purple: #8B5CF6;
    --warning: #F2994A;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --sidebar-width: 250px;
    --topbar-height: 60px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========================
   LOGIN OVERLAY
   ======================== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(85, 112, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
}

.login-card {
    text-align: center;
    padding: 48px 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-md);
    animation: loginFadeIn 0.5s ease-out;
}

@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-icon {
    margin-bottom: 20px;
    color: var(--primary);
}

.login-icon svg {
    filter: drop-shadow(0 0 8px rgba(85, 112, 241, 0.2));
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-card>p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form input {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
    text-align: center;
    letter-spacing: 0.15em;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.login-form input::placeholder {
    color: var(--text-muted);
    letter-spacing: normal;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    box-shadow: 0 4px 12px rgba(85, 112, 241, 0.25);
}

.btn-login:hover {
    background: #4460E0;
    box-shadow: 0 6px 20px rgba(85, 112, 241, 0.3);
}

.btn-login:active {
    transform: translateY(1px);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    color: var(--error) !important;
    font-size: 0.85rem !important;
    font-weight: 600;
    margin-top: 12px !important;
    margin-bottom: 0 !important;
}

/* ========================
   ADMIN LAYOUT
   ======================== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ========================
   SIDEBAR
   ======================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-height);
}

.sidebar-logo svg {
    width: 34px;
    height: 34px;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
}

.sidebar-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 14px 12px 8px;
    margin-top: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--primary);
    color: #FFFFFF;
    font-weight: 600;
}

.sidebar-link.active svg {
    color: #FFFFFF;
}

.sidebar-link svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.sidebar-link:hover svg {
    opacity: 0.9;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ========================
   MAIN CONTENT
   ======================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ========================
   TOP BAR
   ======================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 28px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb-icon {
    display: flex;
    color: var(--text-muted);
}

.breadcrumb-sep {
    opacity: 0.4;
}

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

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

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 6px 14px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================
   PAGE CONTENT
   ======================== */
.page-content {
    flex: 1;
    padding: 28px;
    max-width: 960px;
    width: 100%;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ========================
   CARDS GRID
   ======================== */
.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ========================
   CONFIG SECTIONS
   ======================== */
.config-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.config-section:hover {
    box-shadow: var(--shadow-md);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    color: var(--primary);
    flex-shrink: 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 18px;
    line-height: 1.5;
}

/* ========================
   FORM
   ======================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.form-group input {
    width: 100%;
    padding: 11px 14px;
    font-size: 0.88rem;
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.token-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.token-input-row input {
    flex: 1;
}

.token-input-row .btn-secondary {
    flex-shrink: 0;
}

.token-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.token-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.token-badge {
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 100px;
    font-weight: 600;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.token-badge.active {
    color: var(--success);
    border-color: rgba(81, 156, 102, 0.25);
    background: var(--success-bg);
}

.token-badge.missing {
    color: var(--error);
    border-color: rgba(204, 95, 95, 0.25);
    background: var(--error-bg);
}

/* ========================
   BUTTONS
   ======================== */
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    white-space: nowrap;
}

.btn-secondary:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn-outline:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.btn-outline.discover:hover {
    color: var(--purple);
    border-color: var(--purple);
    background: rgba(139, 92, 246, 0.06);
}

/* ========================
   POINTS TABLE
   ======================== */
.points-table-wrapper {
    overflow-x: auto;
    margin-bottom: 14px;
    border-radius: var(--radius-xs);
}

.points-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 520px;
}

.points-header {
    display: grid;
    grid-template-columns: 56px 1fr 1fr 1fr 40px;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 4px;
}

.points-header span {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.point-row {
    display: grid;
    grid-template-columns: 56px 1fr 1fr 1fr 40px;
    gap: 8px;
    align-items: center;
}

.point-row input {
    padding: 9px 12px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
    min-width: 0;
}

.point-row input:focus {
    border-color: var(--primary);
    background: #fff;
}

.point-row input::placeholder {
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
}

.point-row .icon-input {
    text-align: center;
    font-size: 1.15rem;
    padding: 7px;
}

.point-row .btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 1.1rem;
}

.point-row .btn-remove:hover {
    color: var(--error);
    border-color: rgba(204, 95, 95, 0.25);
    background: var(--error-bg);
}

.points-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========================
   DISCOVERED PANEL
   ======================== */
.discovered-panel {
    margin-top: 16px;
    padding: 16px;
    background: rgba(139, 92, 246, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: var(--radius-sm);
}

.discovered-panel h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 12px;
}

.discovered-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.discovered-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(139, 92, 246, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.discovered-tag:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: var(--purple);
}

.discovered-tag .tag-label {
    font-family: var(--font);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ========================
   UPLOAD
   ======================== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    overflow: hidden;
    position: relative;
    min-height: 150px;
    background: var(--bg-input);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 8px;
}

.upload-placeholder p {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.upload-placeholder span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-preview {
    position: relative;
}

.upload-preview img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
    background: #f0f0f0;
}

/* ========================
   SAVE BAR
   ======================== */
.save-bar {
    position: sticky;
    bottom: 20px;
    z-index: 50;
    margin-top: 24px;
}

.btn-save {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    box-shadow: 0 4px 16px rgba(85, 112, 241, 0.25);
}

.btn-save:hover {
    background: #4460E0;
    box-shadow: 0 6px 24px rgba(85, 112, 241, 0.3);
}

.btn-save:active {
    transform: translateY(1px);
}

.btn-save.saved {
    background: var(--success);
    box-shadow: 0 4px 16px rgba(81, 156, 102, 0.25);
}

/* ========================
   SCROLLBAR
   ======================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .admin-layout.sidebar-collapsed .sidebar {
        transform: translateX(0);
    }

    .admin-layout.sidebar-collapsed .sidebar~.main-content {
        opacity: 0.3;
        pointer-events: none;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 20px 16px;
    }
}

@media (max-width: 600px) {
    .point-row {
        grid-template-columns: 48px 1fr 1fr 36px;
    }

    .point-row input:nth-child(3) {
        display: none;
    }

    .points-header span:nth-child(3) {
        display: none;
    }

    .points-header {
        grid-template-columns: 48px 1fr 1fr 36px;
    }
}