/**
 * BetterDesk Console v2.0 - Main Stylesheet
 * Reset, layout, and core components
 */

@import url('./variables.css');

/* Google Material Icons */
@import url('https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined');

/* ═══════════════════════════════════════════════════════════════════════════
   CSS RESET
   ═══════════════════════════════════════════════════════════════════════════ */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: var(--line-height);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--accent-blue-hover); }

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

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    outline: none;
}

ul, ol { list-style: none; }

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

/* ═══════════════════════════════════════════════════════════════════════════
   CUSTOM SCROLLBAR
   ═══════════════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

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

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

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

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

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

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

.main-content {
    flex: 1;
    padding: var(--space-lg);
    margin-top: var(--navbar-height);
    max-width: var(--content-max-width);
    width: 100%;
}

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

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.page-subtitle {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
}

.sidebar-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--navbar-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
}

.sidebar-logo .material-icons {
    color: var(--accent-blue);
    font-size: 32px;
}

.sidebar-logo-text {
    /* Always visible */
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: none;
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: var(--space-md);
}

.sidebar-section-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-sm) var(--space-md);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-blue-muted);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.sidebar-link .material-icons {
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-link-text {
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-primary);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-tertiary);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-blue-muted);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   NAVBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--navbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    z-index: var(--z-sticky);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.navbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.navbar-breadcrumb a {
    color: var(--text-secondary);
}

.navbar-breadcrumb a:hover {
    color: var(--text-primary);
}

.navbar-breadcrumb .separator {
    color: var(--text-tertiary);
}

.navbar-breadcrumb .current {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.navbar-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Language selector */
.lang-selector {
    position: relative;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-xs);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

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

.lang-option {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: background var(--transition-fast);
}

.lang-option:hover {
    background: var(--bg-elevated);
}

.lang-option.active {
    color: var(--accent-blue);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

.btn .material-icons {
    font-size: 18px;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
}

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

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

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

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

.btn-icon {
    padding: var(--space-sm);
    min-width: auto;
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-md);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════ */

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-muted);
}

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

.form-input.error {
    border-color: var(--accent-red);
}

.form-error {
    font-size: var(--font-size-sm);
    color: var(--accent-red);
    margin-top: var(--space-xs);
}

.form-hint {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* Search input with icon */
.search-wrapper {
    position: relative;
}

.search-wrapper .material-icons {
    position: absolute;
    left: var(--space-sm);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 20px;
}

.search-wrapper .form-input {
    padding-left: 40px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-title .material-icons {
    color: var(--accent-blue);
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

/* Stat cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all var(--transition-fast);
}

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

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

.stat-card-icon.primary {
    background: var(--accent-blue-muted);
    color: var(--accent-blue);
}

.stat-card-icon.success {
    background: var(--accent-green-muted);
    color: var(--accent-green);
}

.stat-card-icon.danger {
    background: var(--accent-red-muted);
    color: var(--accent-red);
}

.stat-card-icon.warning {
    background: var(--accent-yellow-muted);
    color: var(--accent-yellow);
}

.stat-card-body {
    flex: 1;
}

.stat-card-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: 1;
}

.stat-card-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════ */

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

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

.table th,
.table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.table th {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    white-space: nowrap;
}

.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    color: var(--text-primary);
}

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

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

.table tbody tr.selected {
    background: var(--accent-blue-muted);
}

/* Status badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px var(--space-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-full);
}

.status-badge .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-badge.online {
    background: var(--accent-green-muted);
    color: var(--accent-green);
}

.status-badge.online .status-dot {
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

.status-badge.offline {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.status-badge.offline .status-dot {
    background: var(--text-tertiary);
}

.status-badge.banned {
    background: var(--accent-red-muted);
    color: var(--accent-red);
}

.status-badge.banned .status-dot {
    background: var(--accent-red);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */

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

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

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform var(--transition-fast);
}

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

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

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-primary);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    min-width: 300px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--accent-green);
}

.toast.error {
    border-left: 4px solid var(--accent-red);
}

.toast.warning {
    border-left: 4px solid var(--accent-yellow);
}

.toast.info {
    border-left: 4px solid var(--accent-blue);
}

.toast-icon {
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--accent-green); }
.toast.error .toast-icon { color: var(--accent-red); }
.toast.warning .toast-icon { color: var(--accent-yellow); }
.toast.info .toast-icon { color: var(--accent-blue); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-xs);
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
}

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

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--accent-green); }
.text-danger { color: var(--accent-red); }
.text-warning { color: var(--accent-yellow); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none !important; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

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

.skeleton-text {
    height: 1em;
    display: inline-block;
    min-width: 100px;
}

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

/* Monospace text */
.mono {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    background: var(--bg-tertiary);
    padding: 2px var(--space-xs);
    border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .navbar {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: var(--bg-overlay);
        z-index: calc(var(--z-sticky) - 1);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-fast);
    }
    
    .sidebar.open + .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--space-md);
    }
    
    .stat-cards {
        grid-template-columns: 1fr;
    }
    
    .modal {
        width: 95%;
        max-height: 85vh;
    }
    
    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}
