/* ============================================
   nazeyh.cc License Manager - shared styles
   ============================================ */

:root {
    --bg: #0a0a0f;
    --bg-elev: #14141c;
    --bg-hover: #1c1c28;
    --border: #25253a;
    --text: #ffffff;
    --text-dim: #8a8aa0;
    --text-faint: #5a5a72;
    --primary: #7c5cff;
    --primary-hover: #6e4ef5;
    --primary-faint: rgba(124, 92, 255, 0.12);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(124, 92, 255, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(124, 92, 255, 0.04) 0%, transparent 40%);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: var(--primary);
    color: white;
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.15s;
}
button:hover { background: var(--primary-hover); }
button.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--bg-hover); }
button.danger { background: var(--danger); }
button.danger:hover { background: var(--danger-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
    font-family: inherit;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    width: 100%;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}
label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

/* ===== Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}
.sidebar-brand span { color: var(--text); font-weight: 400; font-size: 0.85rem; display: block; margin-top: 0.2rem; }

.nav-item {
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    transition: all 0.15s;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: block;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
    background: var(--primary-faint);
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 0.85rem;
}

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 100%;
    overflow-x: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-title {
    font-size: 1.8rem;
    font-weight: 700;
}
.page-subtitle {
    color: var(--text-dim);
    margin-top: 0.3rem;
    font-size: 0.95rem;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
}
.stat-label {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}
.stat-sub {
    color: var(--text-faint);
    font-size: 0.85rem;
    margin-top: 0.3rem;
}

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elev);
}
th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }
.row-link { cursor: pointer; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-v1 { background: rgba(138, 138, 160, 0.15); color: var(--text-dim); }
.badge-v2 { background: var(--primary-faint); color: var(--primary); }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-suspended { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-revoked { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-expired { background: rgba(138, 138, 160, 0.15); color: var(--text-dim); }
.badge-pending { background: rgba(124, 92, 255, 0.15); color: var(--primary); }
.badge-info { background: rgba(124, 92, 255, 0.12); color: var(--primary); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-critical { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ===== Forms / dialogs ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}
.modal-title { font-size: 1.2rem; font-weight: 700; }
.modal-close {
    background: transparent;
    color: var(--text-dim);
    padding: 0.3rem 0.6rem;
    font-size: 1.3rem;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar input { max-width: 320px; }
.toolbar select { max-width: 180px; }
.toolbar .spacer { flex: 1; }

/* ===== Empty state ===== */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-faint);
}

/* ===== Loading ===== */
.loading {
    color: var(--text-dim);
    text-align: center;
    padding: 2rem;
}

/* ===== Login page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-box {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}
.login-title {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, #b294ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}
.login-sub {
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.4rem;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}
.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ===== KV details ===== */
.kv {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0.5rem 1.2rem;
    font-size: 0.93rem;
}
.kv dt { color: var(--text-dim); }
.kv dd { color: var(--text); word-break: break-word; }

/* ===== Code ===== */
code, .mono {
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 0.88em;
    background: var(--bg);
    padding: 0.15em 0.45em;
    border-radius: 4px;
}
pre.codeblock {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ===== Pulse (live indicator) ===== */
.pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; overflow-x: auto; padding: 0.8rem; }
    .sidebar-brand { display: none; }
    .sidebar-footer { display: none; }
    .content { padding: 1.2rem; }
    .form-grid { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 0.2rem; }
    .kv dt { color: var(--text-faint); margin-top: 0.6rem; }
}
