/**
 * ThermoSpa Dark Theme
 * Tema escuro mantendo identidade visual iOS
 *
 * Aplica quando html/body tem classe .theme-dark
 */

/* ========================================
   DARK THEME - CORES BASE
   ======================================== */

.theme-dark {
    /* Backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-elevated: #3a3a3c;

    /* Texto */
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-tertiary: #98989d;
    --text-quaternary: #636366;

    /* Separadores */
    --separator: rgba(84, 84, 88, 0.6);
    --separator-opaque: #38383a;

    /* Fills */
    --fill-primary: rgba(120, 120, 128, 0.36);
    --fill-secondary: rgba(120, 120, 128, 0.32);
    --fill-tertiary: rgba(118, 118, 128, 0.24);

    /* Cores de destaque */
    --blue: #0a84ff;
    --blue-light: #409cff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --yellow: #ffd60a;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* ========================================
   BODY & BACKGROUNDS
   ======================================== */

.theme-dark body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* ========================================
   CARDS & CONTAINERS
   ======================================== */

.theme-dark .auth-card,
.theme-dark .profile-card,
.theme-dark .device-card,
.theme-dark .action-card,
.theme-dark .status-card,
.theme-dark .stat-card,
.theme-dark .welcome-section,
.theme-dark .user-info-card,
.theme-dark .auth-links {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    box-shadow: var(--shadow-sm);
}

.theme-dark .card {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
}

/* Hover states */
.theme-dark .device-card:hover,
.theme-dark .action-card:hover,
.theme-dark .profile-card:hover {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
}

/* ========================================
   TEXT & TYPOGRAPHY
   ======================================== */

.theme-dark .page-title,
.theme-dark .auth-title,
.theme-dark .header-title,
.theme-dark .section-title,
.theme-dark .card-title,
.theme-dark .device-name,
.theme-dark .action-title,
.theme-dark .stat-label,
.theme-dark .user-name-large,
.theme-dark .welcome-text h1,
.theme-dark .sidebar-title {
    color: var(--text-primary);
}

.theme-dark .page-subtitle,
.theme-dark .device-ip,
.theme-dark .device-version,
.theme-dark .device-mode,
.theme-dark .action-desc,
.theme-dark .stat-label,
.theme-dark .user-email,
.theme-dark .welcome-text p,
.theme-dark .form-label {
    color: var(--text-tertiary);
}

/* ========================================
   INPUTS & FORMS
   ======================================== */

.theme-dark .form-input,
.theme-dark .search-input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--separator);
}

.theme-dark .form-input:focus,
.theme-dark .search-input:focus {
    background: var(--bg-elevated);
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.theme-dark .form-input::placeholder,
.theme-dark .search-input::placeholder {
    color: var(--text-quaternary);
}

.theme-dark .form-input:disabled {
    background: var(--bg-secondary);
    color: var(--text-quaternary);
}

.theme-dark .input-icon,
.theme-dark .search-icon {
    color: var(--text-tertiary);
}

.theme-dark .form-input:focus + .input-icon {
    color: var(--blue);
}

/* ========================================
   BUTTONS
   ======================================== */

.theme-dark .btn-primary {
    background: var(--blue);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}

.theme-dark .btn-primary:hover {
    background: var(--blue-light);
    box-shadow: 0 4px 16px rgba(10, 132, 255, 0.5);
}

.theme-dark .btn-google {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--separator);
}

.theme-dark .btn-google:hover {
    background: var(--bg-elevated);
    border-color: var(--blue);
}

.theme-dark .device-action-btn {
    background: var(--fill-primary);
    color: var(--blue);
}

.theme-dark .device-action-btn:hover {
    background: var(--fill-secondary);
}

.theme-dark .device-action-btn.delete {
    color: var(--red);
}

/* ========================================
   HEADER & NAVIGATION
   ======================================== */

.theme-dark .header {
    background: rgba(28, 28, 30, 0.95);
    border-bottom: 1px solid var(--separator);
}

.theme-dark .bottom-nav {
    background: rgba(28, 28, 30, 0.95);
    border-top: 1px solid var(--separator);
}

.theme-dark .nav-item {
    color: var(--text-tertiary);
}

.theme-dark .nav-item.active {
    color: var(--blue);
    background: rgba(10, 132, 255, 0.15);
}

.theme-dark .nav-item:hover {
    color: var(--blue);
}

/* ========================================
   SIDEBAR (DESKTOP)
   ======================================== */

.theme-dark .desktop-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--separator);
}

.theme-dark .sidebar-brand {
    border-bottom: 1px solid var(--separator);
}

.theme-dark .sidebar-nav-item {
    color: var(--text-tertiary);
}

.theme-dark .sidebar-nav-item:hover {
    background: var(--fill-primary);
    color: var(--blue);
}

.theme-dark .sidebar-nav-item.active {
    background: rgba(10, 132, 255, 0.15);
    color: var(--blue);
}

.theme-dark .sidebar-footer {
    border-top: 1px solid var(--separator);
}

/* ========================================
   STATUS BADGES
   ======================================== */

.theme-dark .status-online {
    background: rgba(48, 209, 88, 0.15);
    color: var(--green);
}

.theme-dark .status-offline {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
}

.theme-dark .status-badge {
    background: var(--fill-primary);
}

/* ========================================
   STATS & NUMBERS
   ======================================== */

.theme-dark .stat-number,
.theme-dark .device-temp {
    color: var(--blue);
}

.theme-dark .stat-item,
.theme-dark .device-item {
    background: var(--bg-tertiary);
}

.theme-dark .device-item:hover {
    background: var(--bg-elevated);
}

/* ========================================
   ICONS & ELEMENTS
   ======================================== */

.theme-dark .company-logo,
.theme-dark .sidebar-logo,
.theme-dark .action-icon {
    background: linear-gradient(135deg, var(--blue), var(--blue-light));
}

.theme-dark .device-icon {
    background: linear-gradient(135deg, var(--orange), #ffb340);
}

.theme-dark .user-btn,
.theme-dark .user-avatar,
.theme-dark .user-avatar-large {
    background: var(--bg-tertiary);
}

/* ========================================
   DROPDOWNS & MODALS
   ======================================== */

.theme-dark .user-dropdown {
    background: var(--bg-tertiary);
    border: 1px solid var(--separator);
    box-shadow: var(--shadow-lg);
}

.theme-dark .dropdown-item {
    color: var(--text-primary);
}

.theme-dark .dropdown-item:hover {
    background: var(--fill-primary);
}

.theme-dark .dropdown-item i {
    color: var(--blue);
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */

.theme-dark .alert-success,
.theme-dark .success-message {
    background: rgba(48, 209, 88, 0.15);
    color: var(--green);
    border: 1px solid rgba(48, 209, 88, 0.3);
}

.theme-dark .alert-error {
    background: rgba(255, 69, 58, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 69, 58, 0.3);
}

.theme-dark .form-input.error {
    background: rgba(255, 69, 58, 0.1);
    border-color: var(--red);
}

.theme-dark .form-input.success {
    background: rgba(48, 209, 88, 0.1);
    border-color: var(--green);
}

/* ========================================
   DIVIDERS
   ======================================== */

.theme-dark .divider::before,
.theme-dark .divider::after {
    background: var(--separator);
}

.theme-dark .divider span {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
}

.theme-dark .card-header,
.theme-dark .status-header,
.theme-dark .device-footer {
    border-color: var(--separator);
}

/* ========================================
   EMPTY STATES
   ======================================== */

.theme-dark .empty-icon {
    color: var(--text-quaternary);
}

.theme-dark .empty-title {
    color: var(--text-primary);
}

.theme-dark .empty-subtitle {
    color: var(--text-tertiary);
}

/* ========================================
   PAGINATION
   ======================================== */

.theme-dark .pagination {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
}

.theme-dark .page-btn {
    color: var(--blue);
}

.theme-dark .page-btn:hover {
    background: var(--fill-primary);
}

.theme-dark .page-btn.active {
    background: var(--blue);
    color: var(--text-primary);
}

.theme-dark .page-btn.disabled {
    color: var(--text-quaternary);
}

/* ========================================
   LOADING & SPINNERS
   ======================================== */

.theme-dark .loading-overlay {
    background: rgba(0, 0, 0, 0.85);
}

.theme-dark .loading-spinner {
    border: 3px solid var(--fill-primary);
    border-top-color: var(--blue);
}

/* ========================================
   VIEW TOGGLE BUTTON
   ======================================== */

.theme-dark .view-toggle-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
    color: var(--blue);
    box-shadow: var(--shadow-md);
}

.theme-dark .view-toggle-btn:hover {
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */

.theme-toggle-btn {
    position: fixed;
    bottom: 32px;
    right: 32px; /* Agora é o único botão */
    width: 56px;
    height: 56px;
    background: white;
    border: 1px solid #e5e5ea;
    border-radius: 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff9500;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-dark .theme-toggle-btn {
    background: var(--bg-secondary);
    border-color: var(--separator);
    color: var(--orange);
    box-shadow: var(--shadow-md);
}

.theme-toggle-btn:hover {
    transform: scale(1.1) rotate(20deg);
    box-shadow: 0 8px 32px rgba(255, 149, 0, 0.3);
}

.theme-dark .theme-toggle-btn:hover {
    transform: scale(1.1) rotate(-20deg);
    box-shadow: var(--shadow-lg);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

.theme-toggle-btn i {
    transition: transform 0.3s ease;
}

.theme-toggle-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.theme-dark .theme-toggle-tooltip {
    background: var(--bg-elevated);
}

.theme-toggle-btn:hover .theme-toggle-tooltip {
    opacity: 1;
}

/* Mobile adjustment */
@media (max-width: 768px) {
    .theme-toggle-btn {
        bottom: 100px; /* Acima do bottom nav */
        right: 16px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}

/* ========================================
   SCROLLBARS (WEBKIT)
   ======================================== */

.theme-dark ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.theme-dark ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.theme-dark ::-webkit-scrollbar-thumb {
    background: var(--fill-primary);
    border-radius: 4px;
}

.theme-dark ::-webkit-scrollbar-thumb:hover {
    background: var(--fill-secondary);
}

/* ========================================
   SPECIFIC PAGE ADJUSTMENTS
   ======================================== */

/* Login page */
.theme-dark .logo-container img {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Device details */
.theme-dark .device-header {
    border-bottom-color: var(--separator);
}

/* Password strength */
.theme-dark .strength-indicator {
    background: var(--fill-primary);
}

/* ========================================
   TRANSITIONS & ANIMATIONS
   ======================================== */

.theme-dark * {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease,
                box-shadow 0.3s ease;
}

.theme-dark button,
.theme-dark a,
.theme-dark .form-input,
.theme-dark .card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.theme-dark *:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .theme-dark {
        /* Reverter para light no print */
        filter: invert(0);
    }

    .theme-toggle-btn {
        display: none !important;
    }
}

/* ========================================
   ADDITIONAL ELEMENTS
   ======================================== */

/* Back button */
.theme-dark .back-button {
    background: var(--fill-primary);
    border-color: var(--separator);
    color: var(--text-primary);
}

.theme-dark .back-button:hover {
    background: var(--fill-secondary);
}

/* Tables */
.theme-dark table,
.theme-dark .table {
    color: var(--text-primary);
    border-color: var(--separator);
}

.theme-dark table thead th,
.theme-dark .table thead th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--separator);
}

.theme-dark table tbody tr,
.theme-dark .table tbody tr {
    border-color: var(--separator);
}

.theme-dark table tbody tr:hover,
.theme-dark .table tbody tr:hover {
    background: var(--fill-primary);
}

/* Links */
.theme-dark a {
    color: var(--blue);
}

.theme-dark a:hover {
    color: var(--blue-light);
}

.theme-dark .auth-link {
    color: var(--blue);
}

.theme-dark .auth-link:hover {
    background: rgba(10, 132, 255, 0.15);
    color: var(--blue);
}

/* Password toggle */
.theme-dark .password-toggle {
    color: var(--text-tertiary);
}

.theme-dark .password-toggle:hover {
    color: var(--blue);
}

/* Strength indicator */
.theme-dark .strength-indicator {
    background: var(--fill-primary);
}

/* Logo container */
.theme-dark .logo-container img,
.theme-dark .company-logo img {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* Modal/Sweet Alert */
.theme-dark .swal2-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--separator);
}

.theme-dark .swal2-title {
    color: var(--text-primary);
}

.theme-dark .swal2-html-container {
    color: var(--text-secondary);
}

.theme-dark .swal2-confirm {
    background: var(--blue) !important;
}

.theme-dark .swal2-cancel {
    background: var(--fill-primary) !important;
    color: var(--text-primary) !important;
}

/* Pull to refresh */
.theme-dark .pull-to-refresh {
    color: var(--text-tertiary);
}

/* Auth card before (gradient) */
.theme-dark .auth-card::before,
.theme-dark .welcome-section::before,
.theme-dark .status-card::before {
    background: linear-gradient(90deg, var(--blue), var(--blue-light));
}

/* Notification badge */
.theme-dark .notification-badge {
    background: var(--red);
    color: white;
}

/* Device header */
.theme-dark .device-header {
    border-bottom-color: var(--separator);
}

/* Stats grid animation */
.theme-dark .stat-item:hover {
    background: var(--bg-elevated);
    transform: translateY(-2px);
}

/* Action card improvements */
.theme-dark .action-card::before {
    background: linear-gradient(90deg, transparent, rgba(10, 132, 255, 0.1), transparent);
}

/* Profile card improvements */
.theme-dark .profile-card::before {
    background: linear-gradient(90deg, transparent, rgba(10, 132, 255, 0.1), transparent);
}

/* Disabled state */
.theme-dark .btn-primary:disabled,
.theme-dark .btn-primary[disabled] {
    background: var(--fill-primary);
    color: var(--text-quaternary);
    opacity: 0.5;
}

/* Loading state */
.theme-dark .loading,
.theme-dark .loading-spinner {
    border-color: var(--fill-primary);
    border-top-color: var(--blue);
}

/* Search wrapper */
.theme-dark .search-wrapper {
    position: relative;
}

/* Empty state improvements */
.theme-dark .empty-state {
    color: var(--text-tertiary);
}

/* HR */
.theme-dark hr {
    border-color: var(--separator);
}

/* Code/Pre */
.theme-dark code,
.theme-dark pre {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--separator);
}

/* Blockquote */
.theme-dark blockquote {
    border-left-color: var(--blue);
    color: var(--text-secondary);
}

/* Selection */
.theme-dark ::selection {
    background: rgba(10, 132, 255, 0.3);
    color: var(--text-primary);
}

.theme-dark ::-moz-selection {
    background: rgba(10, 132, 255, 0.3);
    color: var(--text-primary);
}
