@import url("../frontend/extension/fonts/fonts.css");

:root {
    --font-sans: "Outfit", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --accent-color: #7c3aed;
    --accent-warm: #ff7a1a;
    --success-color: #10b981;
    --success-hover: #059669;
    --error-color: #ef4444;
    --error-bg: #fef2f2;
    --warning-bg: #fff7ed;
    --bg-color: #f8fafc;
    --bg-radial: rgba(79, 70, 229, 0.14);
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-bg-solid: #ffffff;
    --soft-surface: #f3f4f6;
    --text-color: #111827;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    --border-color: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 70px rgba(31, 41, 55, 0.14);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --focus-ring: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text-color);
    background:
        radial-gradient(circle at 18% 8%, var(--bg-radial), transparent 30rem),
        radial-gradient(circle at 82% 2%, rgba(255, 122, 26, 0.10), transparent 28rem),
        linear-gradient(180deg, #fffaf5 0%, var(--bg-color) 42%, #eef2ff 100%);
    letter-spacing: -0.01em;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.025) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.admin-login-page {
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

.admin-app-page {
    padding: 56px 24px 64px;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.logout-link,
.card {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.logout-link:focus-visible,
.card:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: rgba(79, 70, 229, 0.44);
}

/* Login */
.login-container {
    width: min(100%, 460px);
    position: relative;
    z-index: 1;
}

.login-card {
    position: relative;
    overflow: hidden;
    padding: 34px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
}

.admin-glass-accent::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-warm), var(--primary-color), var(--accent-color));
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    border: 1px solid rgba(79, 70, 229, 0.22);
    border-radius: 16px;
    color: var(--primary-color);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(255, 122, 26, 0.10));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), var(--shadow-sm);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary-color);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.login-card h1,
.nav h1,
.page-hero h2,
.modal-content h2 {
    margin: 0;
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.login-card h1 {
    font-size: clamp(32px, 8vw, 46px);
}

.login-copy,
.security-footnote,
.page-hero p,
.card p,
.bulk-import-panel p,
.modal-content p,
.form-group small,
.page-indicator {
    color: var(--text-muted);
    line-height: 1.55;
}

.login-copy {
    margin: 14px 0 26px;
    font-size: 15px;
}

.security-footnote {
    margin: 18px 0 0;
    font-size: 12px;
    text-align: center;
}

.error {
    display: none;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(239, 68, 68, 0.22);
    border-radius: 12px;
    color: #991b1b;
    background: var(--error-bg);
    font-size: 13px;
    line-height: 1.4;
}

/* Layout */
.dashboard-container {
    width: min(100%, 1080px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: relative;
    z-index: 1;
}

.dashboard-container.wide {
    width: min(100%, 1220px);
}

.admin-page-shell {
    padding-top: 8px;
}

.nav,
.page-hero,
.toolbar-card,
.table-container,
.bulk-import-panel,
.modal-content {
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
}

.nav {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 22px 24px;
    border-radius: var(--radius-lg);
}

.nav h1 {
    font-size: clamp(22px, 3vw, 32px);
}

.nav-links,
.button-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.logout-link,
.nav-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid rgba(79, 70, 229, 0.16);
    border-radius: 10px;
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.06);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.logout-link:hover,
.nav-action:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 70, 229, 0.3);
    background: rgba(79, 70, 229, 0.10);
}

.page-hero {
    border-radius: var(--radius-lg);
    padding: 30px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.96), rgba(248,250,252,0.92)),
        radial-gradient(circle at 95% 20%, rgba(79, 70, 229, 0.16), transparent 18rem);
}

.page-hero.compact {
    padding: 24px 28px;
}

.page-hero h2 {
    max-width: 760px;
    font-size: clamp(30px, 5vw, 52px);
}

.page-hero.compact h2 {
    font-size: clamp(25px, 4vw, 38px);
}

.page-hero p {
    max-width: 680px;
    margin: 12px 0 0;
    font-size: 15px;
}

/* Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.card {
    position: relative;
    overflow: hidden;
    min-height: 190px;
    display: flex;
    align-items: flex-start;
    gap: 18px;
    padding: 26px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--card-bg-solid);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.card::after {
    content: "";
    position: absolute;
    right: -58px;
    top: -58px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.18), transparent 68%);
    transition: transform 0.24s ease;
}

.card:hover {
    transform: translateY(-5px);
    border-color: rgba(79, 70, 229, 0.24);
    box-shadow: var(--shadow-lg);
}

.card:hover::after {
    transform: scale(1.25);
}

.card-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    color: var(--primary-color);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.10));
    font-size: 22px;
}

.card h2 {
    margin: 2px 0 14px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.card .value {
    color: var(--text-color);
    font-size: clamp(34px, 6vw, 58px);
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 1;
}

.card p {
    margin: 10px 0 0;
    font-size: 14px;
}

/* Forms and controls */
.admin-form,
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    color: #334155;
    font-size: 13px;
    font-weight: 750;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.75);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

textarea {
    min-height: 160px;
    resize: vertical;
    line-height: 1.55;
}

select[multiple] {
    min-height: 100px;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    width: auto;
    padding: 0 16px;
    border: 1px solid rgba(79, 70, 229, 0.16);
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    box-shadow: 0 10px 22px rgba(79, 70, 229, 0.22);
    cursor: pointer;
    font-weight: 750;
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.login-card button[type="submit"] {
    width: 100%;
    margin-top: 4px;
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(79, 70, 229, 0.26);
}

button:active,
.button:active {
    transform: translateY(0);
}

button:disabled,
.button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    transform: none;
    box-shadow: none;
}

.btn-sm {
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

.btn-secondary,
#choice-cancel-btn {
    color: #334155;
    background: #ffffff;
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover,
#choice-cancel-btn:hover {
    background: #f8fafc;
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.export-btn,
#export-btn {
    margin-left: auto;
    background: linear-gradient(135deg, var(--success-color), #0f766e) !important;
    border-color: rgba(16, 185, 129, 0.2);
    box-shadow: 0 10px 22px rgba(16, 185, 129, 0.18);
}

.controls,
.template-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-card {
    padding: 14px;
    border-radius: var(--radius-md);
}

.toolbar-card.subtle {
    box-shadow: var(--shadow-sm);
    background: rgba(255, 255, 255, 0.72);
}

.controls input[type="search"] {
    max-width: 360px;
    flex: 1 1 260px;
}

.template-filters select {
    width: auto;
    min-width: 156px;
    flex: 1 1 156px;
}

/* Bulk import */
.bulk-import-panel {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    padding: 22px;
    border-radius: var(--radius-lg);
}

.bulk-import-panel h3 {
    margin: 0 0 8px;
    font-size: 20px;
}

.bulk-import-panel p {
    margin: 6px 0;
    font-size: 14px;
}

code {
    padding: 2px 6px;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 7px;
    color: #3730a3;
    background: rgba(79, 70, 229, 0.07);
    font-size: 0.9em;
}

.bulk-import-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.bulk-import-report {
    grid-column: 1 / -1;
    max-height: 260px;
    margin: 0;
    overflow: auto;
    padding: 14px;
    border-radius: 12px;
    color: #e5e7eb;
    background: #0f172a;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Tables */
.table-container {
    overflow: auto;
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #475569;
    background: rgba(248, 250, 252, 0.96);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

td {
    color: #1f2937;
    font-size: 14px;
}

tbody tr {
    transition: background 0.18s ease;
}

tbody tr:hover {
    background: rgba(79, 70, 229, 0.035);
}

tbody tr:last-child td {
    border-bottom: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 9px;
    border-radius: 8px;
    color: #4338ca;
    background: #eef2ff;
    font-size: 12px;
    font-weight: 750;
    text-transform: capitalize;
}

.change-plan-btn,
.edit-btn {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
}

.delete-btn {
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.18) !important;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.page-indicator {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 700;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(8px);
}

.modal-content {
    width: min(100%, 860px);
    max-height: 90vh;
    overflow: auto;
    padding: 26px;
    border-radius: var(--radius-lg);
}

.modal-sm {
    width: min(100%, 460px) !important;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 28px;
}

.modal-summary {
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: #f8fafc;
}

.modal-summary p {
    margin: 4px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
}

#save-btn,
.modal-primary-btn,
#plan-modal-confirm-btn {
    width: auto !important;
    padding: 0 20px !important;
}

.modal-message {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
}

.error-message {
    color: #991b1b !important;
    background: var(--error-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.scheduled-message {
    color: #92400e;
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.22);
}

.choice-modal {
    text-align: center;
}

.choice-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 22px;
}

.choice-actions button {
    width: 100%;
}

.button-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
}

/* Sequence dropdown */
.prompt-selector-container {
    position: relative;
}

.dropdown-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 10;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-md);
}

.dropdown-item {
    padding: 11px 13px;
    color: #334155;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover {
    color: var(--primary-color);
    background: rgba(79, 70, 229, 0.06);
}

.selected-list {
    min-height: 56px;
    margin: 12px 0 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: #f8fafc;
}

.selected-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border-color);
    color: #334155;
    font-size: 14px;
}

.selected-list li:last-child {
    border-bottom: none;
}

.remove-btn {
    color: var(--error-color);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 820px) {
    .admin-app-page {
        padding: 20px 14px 34px;
    }

    .nav,
    .controls,
    .bulk-import-panel {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .nav {
        flex-direction: column;
    }

    .nav-links,
    .button-cluster,
    .bulk-import-actions {
        justify-content: flex-start;
    }

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

    .controls input[type="search"] {
        max-width: none;
        flex-basis: 100%;
    }

    .export-btn,
    #export-btn {
        margin-left: 0;
    }

    .page-hero,
    .page-hero.compact,
    .login-card,
    .modal-content {
        padding: 22px;
    }

    .card {
        min-height: 160px;
    }
}

@media (max-width: 520px) {
    .btn-sm,
    .btn-secondary,
    .logout-link,
    .button-cluster button,
    .nav-links button {
        width: 100%;
    }

    .pagination {
        justify-content: stretch;
    }

    .pagination button {
        flex: 1;
    }
}

/* Reports Page Specific */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-color);
    background: var(--soft-surface);
}

.tab.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.report-content {
    display: none;
}

.report-content.active {
    display: block;
}

.report-details-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.65);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.report-details-content {
    background: var(--card-bg-solid);
    border-radius: var(--radius-lg);
    width: min(100%, 860px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.close-details {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-subtle);
    line-height: 1;
    transition: color 0.2s;
}

.close-details:hover {
    color: var(--error-color);
}

.log-entry {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    white-space: pre-wrap;
    word-break: break-all;
}

.log-error { color: #ef4444; background: rgba(239, 68, 68, 0.05); }
.log-warn { color: #f59e0b; background: rgba(245, 158, 11, 0.05); }
.log-info { color: #3b82f6; background: rgba(59, 130, 246, 0.05); }

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    background: var(--soft-surface);
    padding: 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
}

.meta-item b {
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.report-details-content h2 {
    margin: 0 0 20px;
    font-size: 24px;
    letter-spacing: -0.02em;
}
