/* =========================================================
   ChestLink License Dashboard Theme
   Inspired by time-tracker / PM dashboards
   ========================================================= */

/* ---------- Design Tokens ---------- */
:root {
    --bg-gradient-start: #0f172a;        /* dark navy */
    --bg-gradient-end:   #020617;        /* almost black */
    --sidebar-bg:        #020617;        /* pure dark background */
    --card-bg:           #0b1220;        /* dark card */
    --card-bg-soft:      #0f172a;
    --border-subtle:     rgba(148, 163, 184, 0.2);
    --text-main:         #e5e7eb;
    --text-soft:         #9ca3af;
    --text-faded:        #6b7280;
    --accent:            #6366f1;        /* indigo */
    --accent-soft:       rgba(99, 102, 241, 0.15);
    --accent-strong:     #4f46e5;
    --accent-alt:        #22c55e;        /* green */
    --danger:            #ef4444;
    --warning:           #f97316;
    --border-radius-lg:  18px;
    --border-radius-md:  10px;
    --shadow-soft:       0 18px 45px rgba(15, 23, 42, 0.65);
    --shadow-subtle:     0 12px 30px rgba(15, 23, 42, 0.45);
    --input-bg:          #020617;
    --input-border:      rgba(148, 163, 184, 0.35);
}

/* ---------- Global Layout ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
                 "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(circle at top left, #1f2937 0, #020617 55%);
    color: var(--text-main);
    display: flex;
    align-items: stretch;
}

/* App shell: sidebar + main content */
.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    max-width: 1440px;
    width: 100%;
    margin: 24px auto;
    padding: 0 24px;
    gap: 24px;
}

/* Fallback when .app-shell not present (e.g. login page) */
body > .page-wrapper {
    max-width: 1100px;
    width: 100%;
    margin: 60px auto;
    padding: 0 24px;
}

/* ---------- Sidebar ---------- */

.sidebar {
    background: var(--sidebar-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border: 1px solid rgba(31, 41, 55, 0.9);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: radial-gradient(circle at 20% 20%, #f97316 0, #6366f1 40%, #22c55e 80%);
    box-shadow: 0 10px 30px rgba(129, 140, 248, 0.6);
}

.sidebar-title-wrap {
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sidebar-subtitle {
    font-size: 11px;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.sidebar-section-label {
    margin-top: 6px;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-faded);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-soft);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.sidebar-nav a span.icon-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.7);
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: var(--accent-soft);
    color: #eef2ff;
    transform: translateY(-1px);
}

.sidebar-nav a.active span.icon-dot,
.sidebar-nav a:hover span.icon-dot {
    background: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 12px;
    color: var(--text-faded);
}

/* ---------- Main Content Area ---------- */

.main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Top bar (we reuse your existing .top-bar class) */
.top-bar {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(8, 47, 73, 0.9));
    border-radius: var(--border-radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-main);
    box-shadow: var(--shadow-subtle);
    border: 1px solid rgba(148, 163, 184, 0.3);
    margin: 0 0 10px 0;
}

.top-bar-left {
    display: flex;
    flex-direction: column;
}

.top-bar-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.top-bar-subtitle {
    font-size: 13px;
    color: var(--text-soft);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar a {
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    opacity: 0.9;
}

.top-bar a:hover {
    opacity: 1;
}

/* ---------- Cards ---------- */

.card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-subtle);
}

.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-soft);
}

/* ---------- Headings (for existing PHP markup) ---------- */

h1 {
    font-size: 22px;
    margin: 0 0 6px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

h2 {
    font-size: 16px;
    margin: 22px 0 8px;
    font-weight: 600;
}

/* ---------- Forms ---------- */

form {
    margin: 0;
}

form label {
    font-size: 13px;
    color: var(--text-soft);
    display: inline-block;
    margin-bottom: 6px;
}

form input[type="text"],
form input[type="password"] {
    padding: 9px 11px;
    width: 280px;
    max-width: 100%;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

form input[type="text"]::placeholder,
form input[type="password"]::placeholder {
    color: var(--text-faded);
}

form input[type="text"]:focus,
form input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
    background: #020617;
}

form button {
    padding: 9px 16px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #22c55e);
    color: #f9fafb;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 10px;
    box-shadow: 0 8px 22px rgba(56, 189, 248, 0.3);
    transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.5);
    filter: brightness(1.05);
}

form button:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.8);
}

.danger-button {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.4);
}

.danger-button:hover {
    box-shadow: 0 12px 30px rgba(248, 113, 113, 0.7);
    filter: brightness(1.03);
}

/* Login card layout (for login.php) */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, #1e293b 0, #020617 55%);
}

.login-card {
    width: 360px;
    max-width: 100%;
    background: var(--card-bg);
    border-radius: 22px;
    padding: 24px 22px 22px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-subtle);
}

.login-card h1 {
    font-size: 20px;
    margin-bottom: 6px;
}

.login-card p {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-soft);
}

/* ---------- Table (License List) ---------- */

.table-wrapper {
    margin-top: 6px;
    border-radius: var(--border-radius-lg);
    overflow-x: auto;          /* enable horizontal scroll */
    overflow-y: hidden;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-subtle);
    background: var(--card-bg-soft);
}

.table-wrapper table {
    min-width: 1100px;         /* adjust as needed */
}

/* Existing selectors preserved */
table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    border-radius: 0;
}

table thead {
    background: radial-gradient(circle at left, rgba(99, 102, 241, 0.22), rgba(15, 23, 42, 1));
}

table th {
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #e5e7eb;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    white-space: nowrap;
}

table td {
    padding: 9px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
    color: var(--text-main);
}

/* Zebra striping with subtle highlight */
tbody tr:nth-child(odd) {
    background: rgba(15, 23, 42, 0.9);
}

tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.75);
}

tbody tr:hover {
    background: rgba(39, 55, 89, 0.95);
}

/* Make long text truncated with ellipsis where needed */
.table-ellipsis {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Status Badges ---------- */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #f9fafb;
}

.status-unused {
    background: rgba(249, 115, 22, 0.16);
    color: #fdba74;
    box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.5);
}

.status-active {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}

.status-revoked {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.65);
}

/* ---------- Message Banners ---------- */

.message {
    padding: 10px 12px;
    margin: 8px 0 12px;
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid transparent;
}

.message.success {
    background: rgba(22, 163, 74, 0.15);
    color: #bbf7d0;
    border-color: rgba(22, 163, 74, 0.5);
}

.message.error {
    background: rgba(220, 38, 38, 0.08);
    color: #fecaca;
    border-color: rgba(248, 113, 113, 0.6);
}

/* ---------- Utility / Misc ---------- */

.muted {
    color: var(--text-soft);
    font-size: 12px;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* ---------- Code-style chip for license keys ---------- */

.code-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.45);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: #e5e7eb;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
    white-space: nowrap;
}

.code-chip--large {
    padding: 6px 12px;
    font-size: 13px;
}

.code-chip:hover {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

/* ---------- Copy toast notification ---------- */

.copy-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.copy-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.copy-toast-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(34, 197, 94, 0.7);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.9);
}

.copy-toast-circle {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-toast-check {
    color: #22c55e;
    font-size: 16px;
    font-weight: 700;
}

.copy-toast-text {
    font-size: 13px;
    color: #e5e7eb;
}

/* ---------- Modal (License Details) ---------- */

body.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    display: none; /* toggled to flex in JS */
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-card {
    width: 720px;
    max-width: 95vw;
    background: radial-gradient(circle at top left, #1e293b 0, #020617 65%);
    border-radius: 22px;
    padding: 18px 20px 18px;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 2px;
    word-break: break-all;
}

.modal-close {
    background: transparent;
    border: none;
    color: #e5e7eb;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 999px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.modal-close:hover {
    background: rgba(15, 23, 42, 0.6);
    transform: translateY(-1px);
}

.modal-body {
    margin-top: 6px;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 22px;
}

.modal-label {
    font-size: 11px;
    color: var(--text-faded);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-bottom: 2px;
}

.modal-value {
    font-size: 13px;
    color: var(--text-main);
    word-break: break-all;
}

/* clickable rows */

.license-row {
    cursor: pointer;
}

.license-row:hover {
    background: rgba(55, 65, 101, 0.95);
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        margin-top: 20px;
    }

    .sidebar {
        order: 2;
    }

    .main {
        order: 1;
    }
}

@media (max-width: 768px) {
    body > .page-wrapper {
        margin-top: 32px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    table th,
    table td {
        font-size: 12px;
    }

    .sidebar {
        padding: 16px;
    }
}