/* ==========================================================================
   NEPHBOX SHARED COMPONENTS
   --------------------------------------------------------------------------
   Baseline styling for the UI vocabulary that recurs across pages: surfaces,
   buttons, form controls, tables, modals, badges, focus states.

   Load order matters:  tokens.css -> components.css -> <page>.css
   Page stylesheets load last and therefore win on equal specificity, so a
   page can still override anything here without !important.

   The glass treatment used to live only in dashboard.css, which meant the
   dashboard looked like frosted glass while library/gameservers/suggestions/
   support/admin used flat opaque panels. It is defined once here and applied
   to every recurring surface.
   ========================================================================== */

/* ==========================================================================
   BASE
   ========================================================================== */

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-light);
    background: var(--bg-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Layered brand-glow page backdrop. */
.app-backdrop {
    background: var(--backdrop);
    background-attachment: fixed;
}

/* ==========================================================================
   FOCUS
   Keyboard users previously had no reliable focus indicator on buttons or
   inputs. :focus-visible keeps it off mouse clicks.
   ========================================================================== */

:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
    border-radius: var(--radius-sm);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: var(--focus-outline);
    outline-offset: var(--focus-offset);
    box-shadow: var(--focus-ring);
}

/* Remove the default ring only where we replace it. */
:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   GLASS SURFACES
   ========================================================================== */

.glass,
.card,
.stat-card,
.info-box,
.table-container,
.modal-content {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glass);
}

/* Sheen along the top edge, matching the dashboard service cards. */
.glass-sheen {
    position: relative;
}

.glass-sheen::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), transparent 40%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.6;
}

.card,
.stat-card {
    padding: var(--space-6);
    transition: transform var(--transition),
                box-shadow var(--transition),
                border-color var(--transition);
}

.card:hover,
.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-brand-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-light);
}

/* ==========================================================================
   TYPOGRAPHY
   ========================================================================== */

.page-header {
    margin-bottom: var(--space-8);
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    color: var(--text-light);
    margin-bottom: var(--space-3);
}

.section-title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--text-light);
    margin-bottom: var(--space-6);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

/* Gradient brand text, used for the accented word in page titles. */
.highlight,
.brand-accent {
    background: linear-gradient(135deg, var(--brand-300), var(--primary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--primary-color);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--transition),
                box-shadow var(--transition),
                background var(--transition),
                border-color var(--transition),
                filter var(--transition);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled='true'] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent));
    color: #fff;
    box-shadow: var(--shadow-brand);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.12);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--brand-rgb), 0.5);
}

.btn-secondary {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

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

.btn-ghost:hover:not(:disabled) {
    color: var(--text-light);
    border-color: var(--primary-color);
    background: rgba(var(--brand-rgb), 0.1);
}

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

.btn-danger:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: inherit;
    font-size: var(--text-base);
    transition: border-color var(--transition),
                box-shadow var(--transition),
                background var(--transition);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: var(--focus-ring);
}

.form-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
                      linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 18px) center, calc(100% - 13px) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: var(--space-8);
}

/* Native dropdown list needs an explicit dark background on most browsers. */
.form-select option {
    background: var(--bg-secondary);
    color: var(--text-light);
}

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

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    line-height: 1.4;
}

.status-badge.success { background: rgba(72, 187, 120, 0.15); color: var(--success); border: 1px solid rgba(72, 187, 120, 0.3); }
.status-badge.warning { background: rgba(236, 201, 75, 0.15);  color: var(--warning); border: 1px solid rgba(236, 201, 75, 0.3); }
.status-badge.error   { background: rgba(245, 101, 101, 0.15); color: var(--error);   border: 1px solid rgba(245, 101, 101, 0.3); }
.status-badge.info    { background: rgba(66, 153, 225, 0.15);  color: var(--info);    border: 1px solid rgba(66, 153, 225, 0.3); }

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

.table-container {
    overflow-x: auto;
}

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

.table-container th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.table-container td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.table-container tbody tr {
    transition: background var(--transition-fast);
}

.table-container tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

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

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

.stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    color: var(--text-light);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ==========================================================================
   INFO BOX
   ========================================================================== */

.info-box {
    padding: var(--space-4) var(--space-6);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
}

/* ==========================================================================
   LOADING
   ========================================================================== */

.spinner,
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   SCROLLBAR
   The default light scrollbar was a visible seam against the dark UI.
   ========================================================================== */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--brand-rgb), 0.5);
    background-clip: content-box;
}

/* ==========================================================================
   MOTION PREFERENCES
   Previously only login.css honoured this.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
