/* S6 Command RMM Theme
 * Custom CSS replacing Tailwind - clean, semantic classes
 * Supports dark (default) and light themes via data-theme attribute
 */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Primary Colors - shared */
    --primary: #2b8fff;
    --primary-hover: #1a7ae8;
    --primary-light: rgba(43, 143, 255, 0.1);
    --accent: #70c1ff;

    /* Status Colors - shared */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);

    /* Sizing - shared */
    --radius: 6px;
    --radius-lg: 8px;
    --transition: 0.2s ease;
}

/* ============================================
   DARK THEME (Default)
   ============================================ */
:root, [data-theme="dark"] {
    --background: #0b0d10;
    --surface: #14171c;
    --panel: #1b1f26;
    --panel-hover: #22272f;
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --text: #f0f2f5;
    --text-muted: #a1a6b0;
    --text-dim: #6b7280;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --gradient: linear-gradient(145deg, #1d1f25 0%, #23272f 100%);
    --input-bg: var(--background);
    --scrollbar-thumb: #4b5563;
    --scrollbar-track: var(--background);
}

/* ============================================
   LIGHT THEME
   ============================================ */
[data-theme="light"] {
    --background: #f5f7fa;
    --surface: #ffffff;
    --panel: #ffffff;
    --panel-hover: #f0f2f5;
    --border: rgba(0, 0, 0, 0.08);
    --border-light: rgba(0, 0, 0, 0.12);
    --text: #1a1d21;
    --text-muted: #5f6368;
    --text-dim: #9aa0a6;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --gradient: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    --input-bg: #ffffff;
    --scrollbar-thumb: #c1c7ce;
    --scrollbar-track: var(--background);

    /* Adjusted colors for light mode */
    --primary-light: rgba(43, 143, 255, 0.08);
    --success-light: rgba(16, 185, 129, 0.08);
    --warning-light: rgba(245, 158, 11, 0.08);
    --error-light: rgba(239, 68, 68, 0.08);
    --info-light: rgba(59, 130, 246, 0.08);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

code, pre, .font-mono, .monospace {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
}

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

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

.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================
   HEADER & NAVIGATION
   ============================================ */

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: opacity var(--transition);
}

.logo:hover {
    opacity: 0.8;
}

.logo-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

/* Horizontal Navigation */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-tab {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: all var(--transition);
}

.nav-tab:hover {
    color: var(--text);
    background: var(--panel);
}

.nav-tab.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 500;
}

/* Header Right / User Menu */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.header-btn svg {
    width: 20px;
    height: 20px;
}

/* User Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 200px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition);
    z-index: 100;
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.dropdown-item:hover {
    color: var(--text);
    background: var(--panel-hover);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-item.danger {
    color: var(--error);
    justify-content: center;
    width: 100%;
}

.dropdown-item.danger:hover {
    background: var(--error-light);
}

.dropdown-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.card {
    background: var(--gradient);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.card.clickable {
    cursor: pointer;
}

.card.clickable:hover {
    border-color: var(--accent);
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
}

.stat-value.warning { color: var(--warning); }
.stat-value.error { color: var(--error); }
.stat-value.success { color: var(--success); }

.stat-detail {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.error { background: var(--error-light); color: var(--error); }
.stat-icon.info { background: var(--info-light); color: var(--info); }

/* Alert Cards (with colored left border) */
.alert-card {
    border-left: 4px solid;
}

.alert-card.critical { border-left-color: var(--error); }
.alert-card.warning { border-left-color: var(--warning); }
.alert-card.info { border-left-color: var(--primary); }

/* ============================================
   GRID LAYOUTS
   ============================================ */

.grid {
    display: grid;
    gap: 1.25rem;
}

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

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

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

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .nav-tabs { display: none; }
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-secondary:hover {
    background: var(--panel-hover);
    border-color: var(--border-light);
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
}

/* ============================================
   FORMS
   ============================================ */

/* Global form element styling (for elements without specific classes) */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
select,
textarea {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
input[type="search"]::placeholder,
input[type="url"]::placeholder,
input[type="tel"]::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}

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

.form-input::placeholder {
    color: var(--text-dim);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.form-checkbox {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--text-dim);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle.active {
    background: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
}

.toggle.active::after {
    transform: translateX(16px);
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.open,
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--transition);
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-lg { max-width: 48rem; }
.modal-sm { max-width: 24rem; }

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    transition: color var(--transition);
}

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

.modal-close svg {
    width: 24px;
    height: 24px;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ============================================
   TABLES
   ============================================ */

.table-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.table th {
    text-align: left;
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

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

.table tr:hover td {
    background: var(--panel-hover);
}

/* ============================================
   STATUS INDICATORS
   ============================================ */

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--error); }
.status-dot.warning { background: var(--warning); }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-info { background: var(--info-light); color: var(--info); }

/* ============================================
   TABS
   ============================================ */

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

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

.tab-btn.active,
.tab-btn.tab-active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Additional color utilities */
.text-secondary-400 { color: var(--text-dim); }
.text-secondary-500 { color: var(--text-muted); }
.text-secondary-600 { color: var(--text-muted); }
.hover\:text-secondary-600:hover { color: var(--text-muted); }
.bg-secondary-50 { background: var(--panel); }
.bg-secondary-100 { background: var(--panel); }
.bg-secondary-200 { background: var(--panel-hover); }
.border-secondary-200 { border-color: var(--border); }
.border-secondary-300 { border-color: var(--border-light); }
.border-secondary-400 { border-color: var(--border-light); }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--panel) 25%, var(--panel-hover) 50%, var(--panel) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   TRIAL BANNER
   ============================================ */

.trial-banner {
    background: linear-gradient(90deg, var(--warning), #d97706);
    color: white;
    text-align: center;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.trial-banner.expired {
    background: linear-gradient(90deg, var(--error), #dc2626);
}

.trial-banner-link {
    background: white;
    color: #d97706;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.8rem;
}

.trial-banner.expired .trial-banner-link {
    color: var(--error);
}

.trial-banner-close {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.5rem;
}

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

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   THEME TOGGLE SWITCH
   ============================================ */

.theme-toggle-bar {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9999px;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.theme-toggle-btn:hover {
    color: var(--text);
}

.theme-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.theme-toggle-btn svg {
    width: 16px;
    height: 16px;
}
