/* --- Buttons --- */
.btn {
    border: 1px solid var(--muted2);
    color: var(--fg);
    background: transparent;
    padding: 0.55rem 0.9rem;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn:hover {
    background: rgba(255,255,255,0.1);
}

.btn.primary {
    background: #ffffff;
    color: #000000;
    border-color: transparent;
    font-weight: 700;
}

.btn.primary:hover {
    background: rgba(255, 255, 255, 0.85);
    transform: translateY(-1px);
}

#toggleMirror {
    background: #00ffc6;
}

.btn.danger {
    background: transparent;
    color: #ff6363;
    border-color: #ff6363;
}

.btn.danger:hover {
    background: rgba(255, 99, 99, 0.15);
}

.btn.icon-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
}

/* --- Modal Backdrop --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* Widget Settings Modal - lower z-index so file pickers appear above */
#settingsModal {
    z-index: 500;
}

/* --- Modal Window --- */
.modal {
    width: min(520px, 92vw);
    background: #0c0c0c;
    border: 1px solid var(--tileBorder);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.modal header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--tileBorder);
    font-weight: 700;
    font-size: 1.1rem;
    background: rgba(255,255,255,0.02);
}

.modal .body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal footer {
    padding: 16px 20px;
    border-top: 1px solid var(--tileBorder);
    text-align: right;
    background: rgba(255,255,255,0.02);
}

/* --- Module Selection Grid (Add Modal) --- */
.mods-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mod-card {
    border: 1px solid var(--tileBorder);
    background: #0f0f0f;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.mod-card:hover {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

.mod-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.mod-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.mod-desc {
    font-size: 0.75rem;
    color: var(--muted);
}

/* Locked State */
.mod-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
    position: relative;
}

.mod-card.locked::after {
    content: 'Ã°Å¸â€â€™';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 14px;
}

/* Unlocked Pro card (for Pro users) */
.mod-card.unlocked {
    opacity: 1;
    cursor: pointer;
}

.mod-card.unlocked::after {
    display: none;
}

.mod-card.unlocked .upgrade-cta {
    display: none;
}

/* --- System Features Divider --- */
.mods-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 4px;
}

.mods-divider hr {
    flex: 1;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mods-divider span {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    white-space: nowrap;
}

.mods-grid.system-features {
    margin-top: 8px;
}

/* --- Settings Forms --- */
#settingsForm {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

#settingsForm label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--muted);
}

#settingsForm input[type="text"],
#settingsForm select {
    width: 100%;
    padding: 0.75rem;
    background: #000;
    border: 1px solid var(--tileBorder);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#settingsForm input[type="text"]:focus,
#settingsForm select:focus {
    border-color: var(--accent);
}

#settingsForm option {
    background: #000;
    color: #fff;
    padding: 10px;
}

/* Radio Button Groups */
.radio-group {
    display: flex;
    gap: 20px;
    align-items: center;
}

.radio-group label {
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--fg) !important;
}

.radio-group input[type="radio"] {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* --- Toast Notification --- */
.save-status {
    position: fixed;
    top: 58px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 3000;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.save-status.show {
    opacity: 1;
    transform: translateX(0);
}

.save-status.success {
    background: rgba(6, 202, 160, 0.932);
    border: 1px solid var(--accent);
    color: #000;
}

.save-status.error {
    background: rgba(255, 99, 99, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.save-status.loading {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #fff;
}

/* --- Form Inputs (General) --- */
.form-input {
    background: #000;
    border: 1px solid var(--tileBorder);
    color: #fff;
    padding: 0.7rem;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--accent);
}

/* --- Pro Badge --- */
.pro-badge {
    background: linear-gradient(135deg, #00ffc6 0%, #00cc99 100%);
    color: #000;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(0, 255, 198, 0.4);
    cursor: help;
}

/* ============================================
   PRESENCE SETTINGS MODAL
   ============================================ */

/* --- Camera Preview Section --- */
.presence-preview-section {
    margin-bottom: 1.5rem;
}

.presence-preview {
    width: 100%;
    height: 200px;
    background: #111;
    border: 1px solid var(--tileBorder);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.presence-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.presence-preview-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.presence-preview-placeholder span {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.presence-preview-placeholder p {
    font-size: 0.85rem;
    margin: 0;
}

.presence-preview-status {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 8px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

.presence-preview-status.active {
    color: #00ffc6;
    background: rgba(0, 255, 198, 0.1);
}

.presence-preview-status.detecting {
    color: #ffaa00;
    background: rgba(255, 170, 0, 0.1);
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Presence Sections --- */
.presence-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--tileBorder);
}

.presence-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.presence-section h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.presence-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0 0 0.75rem 0;
}

/* --- Calibrated Users List --- */
.presence-users-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
}

.presence-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--tileBorder);
    border-radius: 8px;
    transition: background 0.15s ease;
}

.presence-user-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.presence-user-avatar {
    width: 36px;
    height: 36px;
    background: rgba(0, 255, 198, 0.1);
    border: 1px solid rgba(0, 255, 198, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.presence-user-info {
    flex: 1;
    min-width: 0;
}

.presence-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 2px;
}

.presence-user-dashboard {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.presence-user-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.presence-user-select {
    background: #000;
    border: 1px solid var(--tileBorder);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    max-width: 140px;
}

.presence-user-select:focus {
    border-color: var(--accent);
    outline: none;
}

.presence-user-delete {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid rgba(255, 99, 99, 0.3);
    color: #ff6363;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.15s ease;
}

.presence-user-delete:hover {
    background: rgba(255, 99, 99, 0.15);
    border-color: #ff6363;
}

/* Empty State */
.presence-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px dashed var(--tileBorder);
}

/* --- Add New User Form --- */
.presence-add-user {
    display: flex;
    gap: 10px;
}

.presence-add-user input {
    flex: 1;
}

.presence-add-user .btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Calibration Status --- */
.presence-calibration-status {
    margin-top: 10px;
    font-size: 0.85rem;
    min-height: 24px;
}

.presence-calibration-status.progress {
    color: #ffaa00;
}

.presence-calibration-status.success {
    color: #00ffc6;
}

.presence-calibration-status.error {
    color: #ff6363;
}

/* Calibration Progress Bar */
.presence-calibration-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.presence-calibration-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00ffc6, #00cc99);
    border-radius: 3px;
    transition: width 0.2s ease;
}

/* --- Danger Zone --- */
.presence-danger {
    background: rgba(255, 99, 99, 0.05);
    border: 1px solid rgba(255, 99, 99, 0.2);
    border-radius: 10px;
    padding: 1rem;
    margin-top: 0.5rem;
}

.presence-danger h3 {
    color: #ff6363;
}

/* ============================================
   END PRESENCE MODAL STYLES
   ============================================ */