/* ===== CSS Variables ===== */
:root {
    color-scheme: dark;
    /* Background */
    --bg-primary: #0b0d14;
    --bg-secondary: #11141d;
    --bg-card: rgba(255, 255, 255, 0.02);
    --bg-header: rgba(11, 13, 20, 0.8);
    --bg-input: rgba(255, 255, 255, 0.03);
    --bg-input-focus: rgba(255, 255, 255, 0.05);
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-hover-strong: rgba(255, 255, 255, 0.1);
    --bg-table-header: rgba(255, 255, 255, 0.02);
    --bg-username: rgba(255, 255, 255, 0.04);

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Text */
    --text-primary: #e4e7ed;
    --text-secondary: #8b90a0;
    --text-muted: #5a5f72;

    /* Accent */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);

    /* Status colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);

    /* Shadows & overlay */
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --modal-overlay: rgba(0, 0, 0, 0.6);

    /* Radii */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* ===== Light Theme ===== */
[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.75);
    --bg-header: rgba(255, 255, 255, 0.75);
    --bg-input: rgba(0, 0, 0, 0.02);
    --bg-input-focus: rgba(0, 0, 0, 0.04);
    --bg-hover: rgba(0, 0, 0, 0.03);
    --bg-hover-strong: rgba(0, 0, 0, 0.06);
    --bg-table-header: rgba(0, 0, 0, 0.02);
    --bg-username: rgba(0, 0, 0, 0.04);

    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.14);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-glow: rgba(37, 99, 235, 0.2);

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
    --modal-overlay: rgba(0, 0, 0, 0.3);
}

/* ===== Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Subtle background texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.07), transparent);
    pointer-events: none;
    z-index: 0;
}

[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37, 99, 235, 0.04), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.03), transparent);
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 56px;
    display: flex;
    align-items: center;
    background: var(--bg-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 17px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s;
    color: var(--text-secondary);
    margin-right: 6px;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* Language toggle button */
.lang-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s;
    color: var(--text-secondary);
    margin-right: 12px;
}

.lang-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.header-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.nav-right {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}

.username {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    padding: 6px 14px;
    background: var(--bg-username);
    border-radius: var(--radius-full);
    margin-right: 4px;
}

.username:empty {
    display: none;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    transition: all 0.2s;
}

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

/* ===== Burger menu ===== */
.burger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 6px;
    transition: all 0.2s;
}

.burger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 2px;
    transition: all 0.2s;
}

.burger-btn:hover {
    border-color: var(--accent);
}

.burger-btn:hover span {
    background: var(--accent);
}

.burger-btn.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.burger-btn.open span:nth-child(2) {
    opacity: 0;
}

.burger-btn.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.burger-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    flex-direction: column;
    gap: 8px;
    z-index: 999;
    box-shadow: var(--shadow);
}

.burger-menu.open {
    display: flex;
}

.burger-menu .btn {
    width: 100%;
    justify-content: center;
}

/* ===== Main content ===== */
.main {
    position: relative;
    z-index: 1;
    padding: 96px 24px 60px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Buttons ===== */
.btn {
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-hover-strong);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

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

.btn-danger-ghost:hover {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: #d97706;
}

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

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.btn-small {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
    line-height: 1;
}

.btn-small:hover {
    background: var(--bg-hover-strong);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ===== Device grid ===== */
.devices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.devices-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.devices-grid {
    display: grid;
    gap: 16px;
}

@media (max-width: 768px) {
    .devices-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .devices-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
    .devices-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Device card ===== */
.device-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.device-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(59, 130, 246, 0.06), transparent 40%);
    opacity: 0;
    transition: opacity 0.3s;
}

.device-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

.device-card:hover::before {
    opacity: 1;
}

.device-card.add-card {
    border: 2px dashed var(--border-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    min-height: 180px;
}

.device-card.add-card:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

.device-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.status-badge.online {
    background: var(--success-bg);
    color: var(--success);
}

.status-badge.online::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s infinite;
}

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

.status-badge.offline::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.device-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.device-preview div {
    display: flex;
    justify-content: space-between;
}

.device-preview div span:first-child {
    color: var(--text-muted);
}

.temp-pass {
    font-size: 12px;
    color: var(--warning);
    font-family: 'SF Mono', 'Fira Code', monospace;
    margin-top: 8px;
    padding: 6px 10px;
    background: var(--warning-bg);
    border-radius: var(--radius-sm);
    display: inline-block;
}

.delete-device {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-device:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ===== Modals ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    background: var(--modal-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 8% auto;
    padding: 32px;
    width: 90%;
    max-width: 460px;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.close {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: none;
    border: none;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
}

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

.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus,
.form-group select:-webkit-autofill,
.form-group select:-webkit-autofill:hover,
.form-group select:-webkit-autofill:focus {
    background-color: var(--bg-input) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
    border: 1px solid var(--border);
    color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.password-wrapper input:-webkit-autofill,
.password-wrapper input:-webkit-autofill:hover,
.password-wrapper input:-webkit-autofill:focus {
    background-color: var(--bg-input) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--bg-input) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
    border: 1px solid var(--border);
    color: var(--text-primary) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-input-focus);
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group input[type="file"] {
    padding: 8px;
    cursor: pointer;
}

.form-group input[type="file"]::file-selector-button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    margin-right: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

/* ===== Password toggle ===== */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    padding-right: 44px !important;
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
    user-select: none;
    display: flex;
    align-items: center;
}

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

/* ===== Device page ===== */
.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.device-header h2 {
    font-size: 28px;
    font-weight: 700;
}

.device-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.device-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color 0.3s;
}

.device-section:hover {
    border-color: var(--border-hover);
}

.device-section h3 {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-buttons,
.om-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn,
.om-btn {
    padding: 10px 22px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.25s;
}

.mode-btn:hover,
.om-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.mode-btn.active,
.om-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Time controls */
.time-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-row {
    display: flex;
    gap: 24px;
}

.time-picker-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.time-picker-group label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.time-picker-group input[type="datetime-local"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
    color-scheme: dark;
}

[data-theme="light"] .time-picker-group input[type="datetime-local"] {
    color-scheme: light;
}

.time-picker-group input[type="datetime-local"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-input-focus);
}

.time-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

@media (max-width: 640px) {
    .time-row {
        flex-direction: column;
        gap: 16px;
    }
}

/* Counter / Delay / Flat controls */
.counter-control,
.delay-control,
.flat-control {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.counter-control input[type="range"] {
    flex: 1;
    min-width: 200px;
    accent-color: var(--accent);
    height: 6px;
}

.delay-control input[type="number"] {
    width: 90px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    text-align: center;
}

.delay-control input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Temp password */
.temp-pass-control {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.temp-pass-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    padding: 10px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--warning);
    min-width: 120px;
}

/* ===== Pending indicators ===== */
.pending-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    transition: background 0.3s;
}

.pending-indicator.pending-active {
    background: var(--danger);
    animation: pulse 1.5s infinite;
}

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

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

/* ===== Timezone ===== */
.timezone-control {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.timezone-control select {
    padding: 10px 36px 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    min-width: 210px;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b90a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.timezone-control select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== Notification settings ===== */
.notification-settings {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.checkbox-label:hover {
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
    border-radius: 4px;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

.notif-table,
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.notif-table th,
.admin-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-table-header);
    border-bottom: 2px solid var(--border);
}

.notif-table td,
.admin-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.notif-table tr:hover,
.admin-table tr:hover {
    background: var(--bg-hover);
}

.notif-table tr.unread {
    background: var(--accent-glow);
}

.notif-table tr.unread:hover {
    background: rgba(59, 130, 246, 0.08);
}

/* ===== Admin ===== */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 32px;
    background: var(--bg-table-header);
    border-radius: var(--radius-full);
    padding: 4px;
    display: inline-flex;
}

.tab-btn {
    padding: 9px 22px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-full);
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

.admin-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.import-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.import-result {
    margin-top: 20px;
    padding: 14px;
    border-radius: var(--radius);
    font-size: 14px;
}

/* ===== Notifications badge ===== */
.notification-badge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    z-index: 1000;
    font-weight: 700;
    font-size: 14px;
    transition: transform 0.2s;
}

.notification-badge:hover {
    transform: scale(1.1);
}

/* ===== Toast notifications ===== */
#toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 300px;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: toastIn 0.35s ease;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.toast.toast-success {
    border-left: 3px solid var(--success);
}

.toast.toast-error {
    border-left: 3px solid var(--danger);
}

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

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message {
    color: var(--text-primary);
    flex: 1;
}

.toast.toast-removing {
    animation: toastOut 0.25s ease forwards;
}

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

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* ===== Адаптивная шапка ===== */
    .header {
        height: auto;
        min-height: 56px;
        padding: 8px 0;
    }

    .header-content {
        padding: 0 12px;
    }

    .nav {
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav-right {
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav-links {
        flex-wrap: wrap;
        gap: 6px;
    }

    .burger-btn {
        display: flex;
    }

    .nav-mobile-hide {
        display: none !important;
    }

    .username {
        font-size: 12px;
        padding: 4px 10px;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
        font-size: 15px;
        margin-right: 2px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
        gap: 4px;
    }

    .btn-small {
        padding: 3px 8px;
        font-size: 10px;
    }

    .nav-link {
        font-size: 12px;
        padding: 6px 10px;
    }

    .main {
        padding: 76px 12px 40px;
    }

    .device-section {
        padding: 18px;
    }

    .device-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .device-header h2 {
        font-size: 22px;
    }

    .mode-buttons,
    .om-buttons {
        flex-direction: column;
    }

    .mode-btn,
    .om-btn {
        width: 100%;
        text-align: center;
    }

    .modal-content {
        margin: 4% auto;
        padding: 24px;
    }

    .toast {
        min-width: auto;
        max-width: calc(100vw - 48px);
    }

    #toast-container {
        right: 12px;
        left: 12px;
    }

    .admin-tabs {
        display: flex;
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        font-size: 13px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 0;
    }

    .nav {
        gap: 4px;
    }

    .nav-right {
        gap: 4px;
    }

    .nav-links {
        gap: 4px;
    }

    .username {
        font-size: 11px;
        padding: 3px 8px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .nav-link {
        font-size: 11px;
        padding: 5px 8px;
    }
}
