/* ═══════════════════════════════════════════════════════════════
   JOVENA Licence Server — Design System
   ═══════════════════════════════════════════════════════════════ */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1e2a4a;
    --bg-input: #0d1b2a;
    --border: #2a2a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent: #667eea;
    --accent-hover: #5a6fd8;
    --accent-glow: rgba(102, 126, 234, 0.3);
    --green: #10b981;
    --green-bg: #0d3326;
    --yellow: #f59e0b;
    --yellow-bg: #3d2e0a;
    --red: #ef4444;
    --red-bg: #3d1111;
    --purple: #a855f7;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ─── LOGIN ─── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    width: 400px;
    box-shadow: var(--shadow), 0 0 60px rgba(102, 126, 234, 0.1);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.login-header p {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 14px;
}

/* ─── FORMS ─── */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.error-msg {
    color: var(--red);
    font-size: 13px;
    margin: 8px 0;
    padding: 8px 12px;
    background: var(--red-bg);
    border-radius: var(--radius-sm);
}

/* ─── BUTTONS ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-success {
    background: var(--green);
    color: #fff;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-warning {
    background: var(--yellow);
    color: #000;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    padding: 6px 10px;
    font-size: 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ─── APP LAYOUT ─── */
.app {
    display: flex;
    min-height: 100vh;
}

/* ─── SIDEBAR ─── */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 28px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.sidebar-header small {
    color: var(--text-muted);
    font-size: 11px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

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

/* ─── MAIN ─── */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 28px 32px;
}

/* ─── VIEWS ─── */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.view-header h1 {
    font-size: 22px;
    font-weight: 600;
}

/* ─── STATS ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.stat-value.green {
    color: var(--green);
}

.stat-value.yellow {
    color: var(--yellow);
}

.stat-value.red {
    color: var(--red);
}

.stat-value.accent {
    color: var(--accent);
}

/* ─── PANELS ─── */
.panel-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.panel h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ─── TABLES ─── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:hover {
    background: var(--bg-hover);
}

/* ─── BADGES ─── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-active {
    background: var(--green-bg);
    color: var(--green);
}

.badge-expired {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-revoked {
    background: var(--red-bg);
    color: var(--red);
}

.badge-online {
    background: var(--green-bg);
    color: var(--green);
}

.badge-warning {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-offline {
    background: var(--red-bg);
    color: var(--red);
}

/* ─── FILTERS ─── */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar select,
.filters-bar input {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

/* ─── MODAL ─── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 520px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

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

/* ─── TOAST ─── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow);
    max-width: 360px;
}

.toast-success {
    background: var(--green);
    color: #fff;
}

.toast-error {
    background: var(--red);
    color: #fff;
}

.toast-info {
    background: var(--accent);
    color: #fff;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

/* ─── KEY DISPLAY ─── */
.key-display {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
    margin: 12px 0;
}

/* ─── EMPTY STATE ─── */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state .emoji {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header div,
    .nav-item span:not(.nav-icon),
    .sidebar-footer {
        display: none;
    }

    .sidebar-header {
        justify-content: center;
        padding: 16px;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .main-content {
        margin-left: 60px;
        padding: 16px;
    }

    .panel-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}