/* License Admin Console - Glassmorphism Dark Theme */
/* Matches m365-dashboard design language */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: #13131b;
    --bg-panel: #16161e;
    --bg-card-hover: #1a1a24;
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.14);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #4f8ff7;
    --accent-hover: #3b7ce5;
    --accent-glow: rgba(79, 143, 247, 0.15);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* =========================================================
   LOGIN SCREEN
   ========================================================= */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-screen::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, rgba(124, 58, 237, 0.04) 40%, transparent 70%);
    pointer-events: none;
}

.login-container {
    background: rgba(15, 22, 41, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(40px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo svg { margin-bottom: 20px; filter: drop-shadow(0 4px 12px rgba(59, 130, 246, 0.3)); }

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

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

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

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}

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

.form-input::placeholder { color: var(--text-muted); }
.form-input[readonly] { opacity: 0.6; cursor: not-allowed; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    width: 100%;
    padding: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(59, 130, 246, 0.35); }

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover { background: var(--bg-glass-hover); }

.btn-danger {
    background: var(--danger);
    color: white;
}

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

.btn-success {
    background: var(--success);
    color: white;
}

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

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

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

.login-error {
    display: none;
    padding: 10px 14px;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 16px;
}

/* =========================================================
   APP LAYOUT
   ========================================================= */

.app-layout {
    display: none;
    min-height: 100vh;
}

.app-layout.active { display: flex; }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo svg { flex-shrink: 0; }

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

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

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

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

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

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

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

.sidebar-footer .btn { width: 100%; }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Main content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* =========================================================
   VIEW HEADER
   ========================================================= */

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

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

.view-header-actions {
    display: flex;
    gap: 8px;
}

/* =========================================================
   STATS CARDS
   ========================================================= */

.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 rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.35);
}

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

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.stat-icon.yellow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

/* =========================================================
   TABLE
   ========================================================= */

.table-container {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

.table-toolbar .search-input {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.search-input {
    padding: 8px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

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

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tab {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-tab:hover { background: var(--bg-glass-hover); }
.filter-tab.active { background: var(--accent-glow); color: var(--accent); border-color: var(--border-active); }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

tbody tr:hover { background: var(--bg-glass); }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* =========================================================
   BADGES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-expired { background: var(--warning-bg); color: var(--warning); }
.badge-revoked { background: var(--danger-bg); color: var(--danger); }
.badge-starter { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.badge-professional { background: var(--info-bg); color: var(--info); }
.badge-enterprise { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

/* Role badges */
.badge-role-admin { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-role-manager { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-role-viewer { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

/* =========================================================
   MODAL
   ========================================================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

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

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.form-group select:focus { border-color: var(--accent); }
.form-group select option { background: var(--bg-secondary); }

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* =========================================================
   TOAST NOTIFICATIONS
   ========================================================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    max-width: 400px;
}

.toast-success { background: var(--success-bg); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.toast-error { background: var(--danger-bg); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }
.toast-warning { background: var(--warning-bg); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* =========================================================
   LICENSE KEY DISPLAY
   ========================================================= */

.license-key-display {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    word-break: break-all;
    color: var(--accent);
    position: relative;
    margin: 16px 0;
}

.license-key-display .copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* =========================================================
   DETAIL PANEL
   ========================================================= */

.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    font-size: 13px;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
}

/* =========================================================
   VIEW SECTIONS
   ========================================================= */

.view-section { display: none; }
.view-section.active { display: block; }

/* =========================================================
   SETTINGS
   ========================================================= */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 24px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
}

.settings-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

/* =========================================================
   UTILITY
   ========================================================= */

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.hidden { display: none !important; }

/* =========================================================
   SCROLLBAR
   ========================================================= */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* =========================================================
   DASHBOARD CHARTS
   ========================================================= */

.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -2px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chart-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
}

.chart-card-header {
    padding: 20px 24px 0;
}

.chart-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-body {
    display: flex;
    align-items: center;
    height: 260px;
    padding: 16px 24px 24px;
}

.chart-donut-wrap {
    position: relative;
    flex: 1;
    height: 100%;
    min-width: 0;
}

.chart-donut-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-legend-side {
    width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chart-legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chart-legend-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
    min-width: 0;
}

.chart-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.chart-legend-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0.7;
    flex-shrink: 0;
}

/* =========================================================
   PAGINATION
   ========================================================= */

.table-pagination {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-select {
    padding: 6px 10px;
    font-size: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    outline: none;
}

.pagination-select option { background: var(--bg-secondary); }
.pagination-select:focus { border-color: var(--accent); }

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-page {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 0 8px;
    min-width: 90px;
    text-align: center;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1200px) {
    .dashboard-charts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .dashboard-charts { grid-template-columns: 1fr; }
    .chart-body { flex-direction: column; height: auto; }
    .chart-donut-wrap { height: 220px; }
    .chart-legend-side { width: 100%; }
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand-text, .nav-section-label, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 12px; }
    .main-content { margin-left: 60px; padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
