/* ============================================
   NEXOY PORTAL — Global Stylesheet
   ============================================ */

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

:root {
    --bg:           #f1f5f9;
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --border:       #e2e8f0;
    --accent:       #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-dark:  #0f172a;
    --text:         #0f172a;
    --muted:        #64748b;
    --success:      #16a34a;
    --success-bg:   #f0fdf4;
    --success-border:#bbf7d0;
    --danger:       #dc2626;
    --danger-bg:    #fef2f2;
    --danger-border:#fecaca;
    --warning:      #d97706;
    --warning-bg:   #fffbeb;
    --warning-border:#fcd34d;
    --radius:       10px;
    --radius-lg:    14px;
    --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:    0 10px 40px rgba(0,0,0,0.1);
    --font:         'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:         'DM Mono', 'Courier New', monospace;
    --sidebar-w:    252px;
    --topbar-h:     58px;
    --transition:   0.15s ease;
}

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

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

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

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo-icon {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.sidebar-logo-icon svg { width: 16px; height: 16px; color: #fff; }

.sidebar-logo-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.sidebar-logo-text em { color: var(--accent); font-style: normal; }

/* Admin sidebar dark variant */
.sidebar--admin {
    background: #0f172a;
    border-right: none;
}

.sidebar--admin .sidebar-logo { border-bottom-color: rgba(255,255,255,0.08); }
.sidebar--admin .sidebar-logo-text { color: #fff; }
.sidebar--admin .sidebar-logo-text em { color: #818cf8; }

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

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    padding: 10px 8px 5px;
    margin-top: 4px;
}

.sidebar--admin .nav-section-label { color: rgba(255,255,255,0.25); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

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

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.sidebar--admin .nav-item { color: rgba(255,255,255,0.5); }
.sidebar--admin .nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar--admin .nav-item.active { background: rgba(99,102,241,0.25); color: #a5b4fc; }

/* Sidebar footer */
.sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar--admin .sidebar-footer { border-top-color: rgba(255,255,255,0.08); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius);
}

.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

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

.sidebar--admin .sidebar-user-name { color: #fff; }

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

.sidebar--admin .sidebar-user-role { color: rgba(255,255,255,0.35); }

.nav-item--logout:hover { background: var(--danger-bg); color: var(--danger); }
.sidebar--admin .nav-item--logout:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* Mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--muted);
    transition: all var(--transition);
}

.topbar-toggle:hover { background: var(--surface-2); color: var(--text); }

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.content {
    padding: 24px;
    flex: 1;
}

/* ============================================
   COMPONENTS
   ============================================ */

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.page-header p {
    font-size: 13.5px;
    color: var(--muted);
    margin-top: 3px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid #94a3b8;
    border-top: 1.5px solid #94a3b8;
    transform: rotate(45deg);
    margin: 0 8px 1px;
    vertical-align: middle;
    font-size: 0;
    color: transparent;
}
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 4px rgba(99,102,241,0.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
    transform: translateY(-1px);
}

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

.btn-secondary:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

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

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.btn-success:hover { background: #dcfce7; }

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

.btn-dark:hover { background: #1e293b; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14.5px; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

thead th {
    text-align: left;
    padding: 9px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 11px 14px; color: var(--text); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active    { background: #dcfce7; color: #15803d; }
.badge-inactive  { background: #f1f5f9; color: var(--muted); }
.badge-suspended { background: #fef3c7; color: #b45309; }
.badge-expired   { background: var(--danger-bg); color: var(--danger); }
.badge-online    { background: var(--accent-light); color: var(--accent); }
.badge-offline   { background: #f1f5f9; color: var(--muted); }
.badge-manual    { background: #fef3c7; color: #b45309; }

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 13px;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-input::placeholder,
.form-textarea::placeholder { color: #cbd5e1; }

.form-select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; padding-right: 36px; }

.form-textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

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

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 18px;
    line-height: 1.5;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: #15803d; }
.alert-error   { background: var(--danger-bg);  border: 1px solid var(--danger-border);  color: var(--danger); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning); }
.alert-info    { background: var(--accent-light); border: 1px solid #c7d2fe; color: var(--accent); }

/* License key */
.license-key {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--accent-light);
    border: 1px solid #c7d2fe;
    padding: 3px 9px;
    border-radius: 6px;
    letter-spacing: 1px;
    color: var(--accent);
    white-space: nowrap;
}

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.15s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-sub   { font-size: 13.5px; color: var(--muted); margin-bottom: 22px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* Avatar */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    border: 1px solid #c7d2fe;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: var(--accent);
    flex-shrink: 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 52px 20px;
    color: var(--muted);
}

.empty-state-icon {
    width: 44px; height: 44px;
    background: var(--surface-2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
    color: #cbd5e1;
}

.empty-state-icon svg { width: 20px; height: 20px; }
.empty-state h3 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty-state p  { font-size: 13.5px; }

/* Checkbox (permissions) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
}

.checkbox-item:hover { border-color: var(--accent); background: var(--accent-light); }

.checkbox-item input[type="checkbox"] {
    width: 15px; height: 15px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Product card */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    cursor: pointer;
}

.product-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(99,102,241,0.12);
    transform: translateY(-2px);
}

.product-card-logo {
    width: 44px; height: 44px;
    border-radius: 10px;
    background: var(--accent-light);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    overflow: hidden;
    color: var(--accent);
}

.product-card-logo img { width: 100%; height: 100%; object-fit: cover; }
.product-card-logo svg { width: 20px; height: 20px; }

.product-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.product-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 14px; }
.product-card-stats { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.product-card-stat strong { color: var(--text); font-weight: 700; display: block; font-size: 16px; }

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

@media (max-width: 1024px) {
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-252px);
        width: 252px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open { display: block; }

    .main { margin-left: 0; }

    .topbar-toggle { display: flex; }

    .content { padding: 16px; }

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

    .product-grid {
        grid-template-columns: 1fr;
    }

    .page-header { flex-direction: column; align-items: flex-start; }

    .card-header { flex-direction: column; align-items: flex-start; }

    table { font-size: 12.5px; }

    thead th, tbody td { padding: 9px 10px; }

    .modal { padding: 20px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .btn-lg { padding: 10px 18px; font-size: 14px; }
}


/* ============================================
   SEARCHABLE SELECT
   ============================================ */

.ss-wrap { position: relative; }

.ss-input {
    cursor: pointer;
    padding-right: 36px !important;
}

.ss-input.ss-active {
    border-color: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom-color: transparent !important;
    box-shadow: none !important;
}

.ss-arrow {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
    font-size: 10px;
    transition: transform 0.15s;
}

.ss-input.ss-active ~ .ss-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.ss-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1.5px solid var(--accent);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 300;
    max-height: 240px;
    overflow-y: auto;
}

.ss-dropdown.open { display: block; }

.ss-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--border);
}

.ss-item:last-child { border-bottom: none; }

.ss-item:hover { background: var(--accent-light); }

.ss-item-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
}

.ss-item-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.ss-state {
    padding: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}

/* Safe separator dot — use instead of · or › characters */
.dot-sep {
    display: inline-block;
    width: 3px;
    height: 3px;
    background: currentColor;
    border-radius: 50%;
    vertical-align: middle;
    opacity: 0.4;
    margin: 0 6px;
}

/* ── Sidebar scroll ──────────────────────────────────────────────────────── */
.sidebar {
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.25);
    border-radius: 99px;
    transition: background 0.2s;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.55);
}

/* Firefox */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.25) transparent;
}

/* ── Settings card section label ─────────────────────────────────────────── */
.card-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

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

.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-sm  { font-size: 12.5px; }
.text-xs  { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }