/* Base Template Styles */

* {
    box-sizing: border-box;
}

/* Hide scrollbar but keep scroll functionality */
html, body, * {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--dashboard-bg);
    color: var(--text-primary);
    overflow-y: scroll; /* Keep scroll functionality */
    min-height: 100vh;
    font-size: 13px;
}

/* Dashboard Wrapper с сеткой */
.dashboard-wrapper {
    position: relative;
    min-height: 100vh;
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* Theme Switcher - встроен в шапку */
.theme-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 12px;
}

.theme-switcher-btn {
    background: transparent;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.1));
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    font-size: 16px;
    color: var(--text-dim, #94a3b8);
}

.theme-switcher-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue, #3b82f6);
    color: var(--accent-blue, #3b82f6);
}

.theme-switcher-btn .theme-icon {
    font-size: 14px;
}

/* Notification toggle button in navbar */
.notification-toggle-btn {
    position: relative;
    background: transparent;
    border: 1px solid var(--border-primary, rgba(255,255,255,0.1));
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    color: var(--text-dim, #94a3b8);
    margin-left: 8px;
}

.notification-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--accent-blue, #3b82f6);
}

.notification-toggle-btn .notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    background: var(--accent-red, #ef4444);
    color: white;
    border-radius: 8px;
    font-size: 10px;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.notification-toggle-btn .notification-badge.visible {
    display: flex;
}

/* ============================================
   UNIFIED TOAST NOTIFICATION SYSTEM
   ============================================ */
.global-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}

.global-toast {
    width: 380px;
    max-width: calc(100vw - 40px);
    background: var(--bg-secondary, #1e293b);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    overflow: hidden;
    opacity: 0;
    transform: translateX(420px);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
}

.global-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.global-toast.hiding {
    opacity: 0;
    transform: translateX(100px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.global-toast-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.global-toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.global-toast-title {
    flex: 1;
}

.global-toast-close {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    line-height: 1;
    transition: opacity 0.2s;
}

.global-toast-close:hover {
    opacity: 1;
}

.global-toast-body {
    padding: 16px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary, #e2e8f0);
    background: var(--bg-primary, #0f172a);
}

/* Toast Types */
.global-toast.success .global-toast-header {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.global-toast.error .global-toast-header {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.global-toast.warning .global-toast-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #1a1a1a;
}

.global-toast.info .global-toast-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* Progress bar for auto-dismiss */
.global-toast-progress {
    height: 3px;
    background: rgba(255,255,255,0.3);
    transform-origin: left;
}

.global-toast.success .global-toast-progress { background: #10b981; }
.global-toast.error .global-toast-progress { background: #ef4444; }
.global-toast.warning .global-toast-progress { background: #f59e0b; }
.global-toast.info .global-toast-progress { background: #3b82f6; }

.theme-switcher-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.1));
    border-radius: 8px;
    padding: 8px;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
}

.theme-switcher-dropdown.open {
    display: flex;
}

.theme-switcher-dropdown label {
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    margin-bottom: 4px;
    padding: 0 4px;
}

.theme-switcher-dropdown select {
    background: var(--bg-tertiary, #0f172a);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-primary, rgba(255,255,255,0.1));
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    width: 100%;
}

.theme-switcher-dropdown select:hover {
    border-color: var(--border-secondary, rgba(255,255,255,0.2));
}

.theme-switcher-dropdown select:focus {
    border-color: var(--accent-blue, #3b82f6);
}

/* ===================== */
/* Dashboard Common Styles */
/* ===================== */

/* Dashboard Header - единый для всех страниц */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(10, 14, 23, 0.9);
    border-bottom: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: var(--accent-blue); /* fallback */
}

/* Dashboard Navigation */
.header-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-btn {
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* Page Container */
.page-container {
    padding: 10px;
    max-width: 1900px;
    margin: 0 10px;
}

/* Dashboard Cards */
.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px var(--card-glow);
}

.widget-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
}

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

.widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-bright);
}

.widget-badge {
    background: var(--accent-blue);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

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

.stat-icon {
    font-size: 20px;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-bright);
}

.stat-subtext {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Device Cards */
.device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.device-item:hover {
    border-color: var(--accent-blue);
    background: var(--bg-card-hover);
}

.device-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.device-icon img {
    width: 24px;
    height: 24px;
}

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

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

.device-path {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-status {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

.device-status.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.device-status.disconnected {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

/* Device Buttons */
.device-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.device-btn:hover {
    transform: scale(1.05);
}

.device-btn.eject:hover {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.device-btn.folders:hover,
.device-btn.check:hover {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    color: white;
}

.device-btn.refresh:hover {
    background: linear-gradient(135deg, var(--accent-yellow), #d97706);
    color: white;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: var(--text-muted);
    text-align: center;
    gap: 10px;
}

.empty-icon {
    font-size: 32px;
    opacity: 0.5;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* WebSocket Connection Status Button */
.ws-connection-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-small);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.2s;
    font-size: 11px;
    font-weight: 500;
    min-width: 120px;
    justify-content: center;
}

.ws-connection-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.ws-connection-btn.connected {
    background: var(--badge-active-bg);
    color: var(--badge-active-text);
    border-color: var(--badge-active-bg);
}

.ws-connection-btn.disconnected {
    background: var(--badge-inactive-bg);
    color: var(--badge-inactive-text);
    border-color: var(--badge-inactive-bg);
}

/* Modal styles - единые для всех страниц */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border: 1px solid var(--border-primary);
    margin: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--spacing-large);
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.modal-header h3,
.modal-title {
    font-size: 1.1em;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-small);
    transition: all 0.2s;
}

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

.modal-body {
    padding: var(--spacing-large);
    background: var(--bg-secondary);
    color: var(--text-primary);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px var(--spacing-large);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Common buttons */
.btn {
    display: inline-block;
    padding: 7px 14px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 1px solid var(--border-secondary);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

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

.btn-success {
    background: var(--btn-success-bg);
    border-color: var(--btn-success-bg);
    color: var(--btn-success-text);
}

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

.btn-danger {
    background: var(--btn-danger-bg);
    border-color: var(--btn-danger-bg);
    color: var(--btn-danger-text);
}

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

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

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