/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: 10px 22px; border: none; border-radius: var(--radius-full);
    font-family: var(--font-body); font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: all var(--duration-fast) var(--ease-smooth);
    position: relative; overflow: hidden; min-height: 42px;
    text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.01em;
}
.btn svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-filled {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-on-primary); box-shadow: var(--shadow-sm);
}
.btn-filled:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); filter: brightness(1.05); }
.btn-filled:active { transform: translateY(0); box-shadow: var(--shadow-xs); }

.btn-tonal {
    background-color: var(--color-primary-surface); color: var(--color-on-primary-surface);
}
.btn-tonal:hover { box-shadow: var(--shadow-sm); filter: brightness(1.04); }

.btn-outlined {
    background: transparent; color: var(--color-primary);
    border: 1.5px solid var(--color-outline);
}
.btn-outlined:hover { border-color: var(--color-primary); background-color: var(--color-primary-surface); }

.btn-text { background: transparent; color: var(--color-primary); padding: 10px 14px; }
.btn-text:hover { background-color: var(--color-primary-surface); }

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

.btn-icon {
    padding: 8px; border-radius: var(--radius-full); min-width: 40px; min-height: 40px;
    background: transparent; color: var(--color-on-surface-muted); border: none;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--duration-fast) var(--ease-smooth);
}
.btn-icon:hover { background-color: var(--color-surface-container-highest); color: var(--color-on-surface); }
.btn-icon svg { width: 22px; height: 22px; fill: currentColor; }

/* Ripple */
.ripple {
    position: absolute; border-radius: 50%; transform: scale(0); pointer-events: none;
    animation: ripple-anim 600ms linear; background-color: rgba(255,255,255,0.25);
}
[data-theme="light"] .ripple { background-color: rgba(0,0,0,0.08); }
@keyframes ripple-anim { to { transform: scale(4); opacity: 0; } }

/* FAB */
.fab {
    position: fixed; bottom: 24px; right: 24px; width: 58px; height: 58px;
    border-radius: var(--radius-lg); border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    color: var(--color-on-primary); box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--duration-normal) var(--ease-spring); z-index: 100;
}
.fab:hover { box-shadow: var(--shadow-xl); transform: scale(1.08) rotate(3deg); }
.fab svg { width: 24px; height: 24px; fill: currentColor; }
@media (max-width: 768px) { .fab { bottom: calc(var(--bottom-nav-h) + 16px); } }

/* ===== CARDS ===== */
.card {
    background-color: var(--color-surface-container);
    border-radius: var(--radius-lg); padding: var(--space-5);
    transition: all var(--duration-normal) var(--ease-smooth);
    border: 1px solid var(--color-outline-subtle);
}
.card-elevated { box-shadow: var(--shadow-sm); border-color: transparent; }
.card-elevated:hover { box-shadow: var(--shadow-md); }
.card-glass {
    background: rgba(255,255,255,0.06); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
}
.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg), var(--shadow-glow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.card-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 600; }
.card-subtitle { font-size: 0.8125rem; color: var(--color-on-surface-muted); margin-top: 2px; }
.card-body { color: var(--color-on-surface-muted); font-size: 0.875rem; }
.card-actions { display: flex; gap: var(--space-2); margin-top: var(--space-4); justify-content: flex-end; }

/* ===== INPUTS ===== */
.input-group { position: relative; margin-bottom: var(--space-5); }
.input-field {
    width: 100%; padding: 18px 16px; padding-top: 26px;
    border: 1.5px solid var(--color-outline); border-radius: var(--radius-md);
    background-color: var(--color-surface-container); color: var(--color-on-surface);
    font-size: 0.9375rem; font-family: var(--font-body);
    transition: all var(--duration-fast) var(--ease-smooth); outline: none;
}
.input-field:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-surface); }
.input-label {
    position: absolute; top: 18px; left: 16px; color: var(--color-on-surface-faint);
    font-size: 0.9375rem; pointer-events: none; transition: all var(--duration-fast) var(--ease-smooth);
}
.input-field:focus ~ .input-label,
.input-field:not(:placeholder-shown) ~ .input-label {
    top: 6px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em;
    color: var(--color-primary);
}
.input-outlined {
    padding: 14px 16px; border: 1.5px solid var(--color-outline); border-radius: var(--radius-md);
    background: transparent; color: var(--color-on-surface); font-size: 0.9375rem;
    font-family: var(--font-body); width: 100%; outline: none;
    transition: border-color var(--duration-fast);
}
.input-outlined:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-surface); }
textarea.input-field, textarea.input-outlined { resize: vertical; min-height: 100px; }
select.input-field, select.input-outlined {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7266' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}

/* ===== SWITCH ===== */
.switch { position: relative; width: 52px; height: 28px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; inset: 0; background-color: var(--color-surface-container-highest);
    border: 2px solid var(--color-outline); border-radius: var(--radius-full);
    cursor: pointer; transition: all var(--duration-normal) var(--ease-spring);
}
.switch-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 50%;
    transform: translateY(-50%); background-color: var(--color-outline);
    border-radius: 50%; transition: all var(--duration-normal) var(--ease-spring);
}
.switch input:checked + .switch-slider { background-color: var(--color-primary); border-color: var(--color-primary); }
.switch input:checked + .switch-slider::before {
    transform: translateY(-50%) translateX(24px); background-color: var(--color-on-primary);
}

/* ===== DIALOG / MODAL ===== */
.dialog-overlay {
    position: fixed; inset: 0; background-color: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    opacity: 0; visibility: hidden; transition: all var(--duration-normal);
    padding: var(--space-4); backdrop-filter: blur(4px);
}
.dialog-overlay.active { opacity: 1; visibility: visible; }
.dialog {
    background-color: var(--color-surface-container-high); border-radius: var(--radius-xl);
    padding: var(--space-6); max-width: 540px; width: 100%; max-height: 90vh;
    overflow-y: auto; box-shadow: var(--shadow-xl);
    transform: scale(0.92) translateY(10px);
    transition: transform var(--duration-normal) var(--ease-spring);
}
.dialog-overlay.active .dialog { transform: scale(1) translateY(0); }
.dialog-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-bottom: var(--space-4); }
.dialog-content { margin-bottom: var(--space-5); color: var(--color-on-surface-muted); }
.dialog-actions { display: flex; gap: var(--space-3); justify-content: flex-end; }
@media (max-width: 768px) {
    .dialog { max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; padding: var(--space-5); }
}

/* ===== SNACKBAR ===== */
.snackbar {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
    background-color: var(--color-surface-container-highest); color: var(--color-on-surface);
    padding: 14px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    z-index: 2000; display: flex; align-items: center; gap: var(--space-3);
    transition: transform var(--duration-normal) var(--ease-spring); max-width: calc(100vw - 32px);
    border: 1px solid var(--color-outline-subtle);
}
.snackbar.active { transform: translateX(-50%) translateY(0); }
.snackbar-action {
    color: var(--color-primary); background: none; border: none; cursor: pointer;
    font-weight: 600; font-family: var(--font-body); white-space: nowrap;
}
@media (max-width: 768px) {
    .snackbar { bottom: calc(var(--bottom-nav-h) + 16px); left: 16px; right: 16px; transform: translateX(0) translateY(100px); }
    .snackbar.active { transform: translateX(0) translateY(0); }
}

/* ===== BADGE / CHIP ===== */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em;
    background-color: var(--color-primary-surface); color: var(--color-on-primary-surface);
}
.badge-error { background-color: var(--color-error-surface); color: var(--color-error); }
.badge-accent { background-color: var(--color-accent-surface); color: var(--color-accent); }

.chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 6px 14px;
    border-radius: var(--radius-full); font-size: 0.8125rem; font-weight: 500;
    border: 1.5px solid var(--color-outline); background: transparent;
    color: var(--color-on-surface-muted); cursor: pointer; transition: all var(--duration-fast);
}
.chip:hover { border-color: var(--color-primary); color: var(--color-on-surface); }
.chip.active { background-color: var(--color-primary-surface); color: var(--color-on-primary-surface); border-color: transparent; }

/* ===== TABLE ===== */
.table-container { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--color-outline-subtle); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 18px; }
th {
    background-color: var(--color-surface-container); font-weight: 600; font-size: 0.75rem;
    color: var(--color-on-surface-faint); letter-spacing: 0.04em; text-transform: uppercase;
}
td { border-top: 1px solid var(--color-outline-subtle); font-size: 0.875rem; }
tr:hover td { background-color: var(--color-surface-container); }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 1.5px solid var(--color-outline-subtle); overflow-x: auto; }
.tab {
    padding: 14px 22px; border: none; background: transparent; color: var(--color-on-surface-muted);
    font-family: var(--font-body); font-size: 0.875rem; font-weight: 600; cursor: pointer;
    position: relative; white-space: nowrap; transition: color var(--duration-fast);
    min-height: 48px; display: flex; align-items: center; gap: var(--space-2);
}
.tab:hover { color: var(--color-on-surface); }
.tab.active { color: var(--color-primary); }
.tab.active::after {
    content: ''; position: absolute; bottom: -1.5px; left: 8px; right: 8px; height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: 3px 3px 0 0;
}

/* ===== LOADING ===== */
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--color-outline-subtle); border-top-color: var(--color-primary);
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
    text-align: center; padding: var(--space-8) var(--space-5); color: var(--color-on-surface-muted);
}
.empty-state svg { width: 72px; height: 72px; fill: var(--color-outline); margin-bottom: var(--space-4); opacity: 0.5; }

/* ===== SETTINGS ===== */
.settings-group { margin-bottom: var(--space-6); }
.settings-group-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin-bottom: var(--space-4); color: var(--color-on-surface); }
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) 0; border-bottom: 1px solid var(--color-outline-subtle);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { flex: 1; }
.settings-label-title { font-size: 0.9375rem; font-weight: 500; }
.settings-label-desc { font-size: 0.8125rem; color: var(--color-on-surface-muted); margin-top: 2px; }

/* ===== CONFIG URL ===== */
.config-url {
    background-color: var(--color-surface-container-highest); padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md); font-family: 'DM Sans', monospace; font-size: 0.8125rem;
    word-break: break-all; display: flex; align-items: center; gap: var(--space-3);
    border: 1px solid var(--color-outline-subtle);
}
