/* ============================================
   Theme CSS Variables
   ============================================ */
:root {
    /* Dark theme (default) */
    --bg-primary: #0E141C;
    --bg-secondary: #1a2332;
    --bg-tertiary: #314B6E;
    --bg-elevated: #1e2d42;
    --bg-input: #0E141C;
    --bg-hover: #607EA2;

    --text-primary: #BDB3A3;
    --text-secondary: #8197AC;
    --text-muted: #607EA2;

    --accent: #8197AC;          /* Weldon Blue */
    --accent-hover: #9AADBC;     /* Lighter Weldon Blue */
    --accent-soft: rgba(129, 151, 172, 0.25);

    --border: #314B6E;
    --border-light: #1e2d42;

    --success: #7A9E8A;          /* Muted teal-green */
    --danger: #C45B5B;           /* Muted red */
    --info: #607EA2;             /* Rackley */

    --shadow: rgba(0, 0, 0, 0.4);
    --overlay: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] {
    --bg-primary: #0E141C;
    --bg-secondary: #1a2332;
    --bg-tertiary: #314B6E;
    --bg-elevated: #1e2d42;
    --bg-input: #0E141C;
    --bg-hover: #607EA2;

    --text-primary: #BDB3A3;
    --text-secondary: #8197AC;
    --text-muted: #607EA2;

    --accent: #8197AC;          /* Weldon Blue */
    --accent-hover: #9AADBC;     /* Lighter Weldon Blue */
    --accent-soft: rgba(129, 151, 172, 0.25);

    --border: #314B6E;
    --border-light: #1e2d42;

    --success: #7A9E8A;          /* Muted teal-green */
    --danger: #C45B5B;           /* Muted red */
    --info: #607EA2;             /* Rackley */

    --shadow: rgba(0, 0, 0, 0.4);
    --overlay: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] {
    --bg-primary: rgba(225, 179, 130, 0.8);      /* Sand Tan - main background */
    --bg-secondary: #f5ebe0;    /* Light cream - cards */
    --bg-tertiary: #ecdcc8;     /* Warm beige - subtle elevation */
    --bg-elevated: #fdfbf8;     /* Near white - modals/elevated */
    --bg-input: #f2e8da;        /* Warm cream for inputs */
    --bg-hover: #e8d4bc;        /* Sand tan lighter - hover */

    --text-primary: #12343b;    /* Night Blue Shadow - primary text */
    --text-secondary: #2d545e;  /* Night Blue - secondary text */
    --text-muted: #5a7a82;      /* Muted blue-grey */

    --accent: #2d545e;          /* Night Blue - accent */
    --accent-hover: #12343b;    /* Night Blue Shadow - accent hover */
    --accent-soft: rgba(45, 84, 94, 0.15);

    --border: #c89666;          /* Sand Tan Shadow - borders */
    --border-light: #d4a878;    /* Lighter sand - subtle borders */

    --success: #4a7a5a;         /* Muted green */
    --danger: #a54545;          /* Muted red */
    --info: #2d545e;            /* Night Blue */

    --shadow: rgba(18, 52, 59, 0.12);
    --overlay: rgba(18, 52, 59, 0.6);
}

/* Light theme icon overrides - make icons dark instead of white */
[data-theme="light"] .notification-icon,
[data-theme="light"] .nav-icon {
    filter: brightness(0) invert(0.25);
}

[data-theme="light"] .page-nav-btn:hover .nav-icon {
    filter: brightness(0) invert(0);
}

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

html {
    font-size: 18px; /* Base size for 1920x1200 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.content {
    height: 100vh;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

/* Page header with nav button */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--bg-secondary);
    backdrop-filter: blur(8px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.notification-btn:hover {
    background: var(--bg-tertiary);
}

.notification-icon {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(1);
    transition: filter 0.2s;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-nav-btn {
    background: var(--bg-secondary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    text-decoration: none;
    padding: 0 1.25rem;
    height: 44px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

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

.page-nav-btn:hover .nav-icon {
    filter: brightness(0) invert(1);
}

.nav-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    filter: brightness(0) invert(1);
    transition: filter 0.2s;
}

/* Home / Cards */
.home-container {
    height: 100%;
    overflow-y: auto;
    padding-bottom: 1rem;
}

/* Note: Groups/Entity/Climate styles moved to entities.css */

/* Person */
.card-person .card-state {
    color: var(--success);
}

.card-person.card-on {
    border-color: var(--success);
}

/* Lock */
.card-lock.card-on {
    border-color: var(--success);
}

.card-lock.card-on .card-state {
    color: var(--success);
}

/* Fan */
.card-fan.card-on .card-icon {
    animation: spin 1s linear infinite;
}

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

/* Vacuum */
.card-vacuum .card-state {
    color: #9c27b0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 95vw;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    animation: modalSlide 0.2s ease;
}

.modal-large {
    max-width: 95vw;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--accent);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* Event details */
.detail-row {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-label {
    color: var(--text-secondary);
    min-width: 80px;
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    flex: 1;
}

/* Form elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

/* Event type toggle */
.type-toggle {
    display: flex;
    gap: 0;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1rem;
}

.type-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.type-btn:hover {
    color: var(--text-primary);
}

.type-btn.active {
    background: var(--accent);
    color: white;
}

/* Select dropdown styling */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238197AC' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Modal buttons */
.modal-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.modal-btn.primary {
    background: var(--accent);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--accent-hover);
}

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

.modal-btn.secondary:hover {
    background: var(--bg-hover);
}

.modal-btn.danger {
    background: var(--danger);
    color: white;
}

.modal-btn.danger:hover {
    background: #c0392b;
}

/* Modal sizes */
.modal-small {
    max-width: 400px;
}

/* Text utilities */
.text-muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Color picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent);
}


/* Time Picker */
.time-picker {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: 8px;
}

.time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.time-btn {
    width: 40px;
    height: 28px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

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

.time-btn:active {
    background: var(--accent);
    color: white;
}

.time-field {
    width: 40px;
    height: 36px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.time-field:hover {
    background: var(--bg-hover);
}

.time-field.active {
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.time-field.ampm-field {
    width: 44px;
    font-size: 1rem;
}

.time-separator {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 2px;
}

.time-unit.ampm {
    margin-left: 8px;
}

/* Location autocomplete */
.location-group {
    position: relative;
}

.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.location-suggestions.active {
    display: block;
}

.location-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.location-suggestion:last-child {
    border-bottom: none;
}

.location-suggestion:hover,
.location-suggestion:active {
    background: var(--bg-tertiary);
}

.suggestion-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.suggestion-text {
    flex: 1;
    word-break: break-word;
}

/* Number pad for time input */
.number-pad {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 16px 16px 0 0;
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px var(--shadow);
}

.number-pad.active {
    transform: translateY(0);
}

.numpad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.5rem;
}

.numpad-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.numpad-done {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 0 4px 0.5rem;
}

.numpad-key {
    height: 56px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.numpad-key:hover {
    background: var(--bg-tertiary);
}

.numpad-key:active {
    background: var(--accent);
}

.numpad-clear {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.numpad-ok {
    background: var(--accent);
    color: white;
}

/* When number pad is open, adjust modal position */
body.numpad-open .modal-content {
    margin-bottom: 280px;
    max-height: calc(90vh - 280px);
}

/* ===== Weather Widget ===== */
.weather-widget {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.weather-widget:hover {
    background: var(--bg-tertiary);
}

.weather-icon {
    font-size: 1.25rem;
}

.weather-temp {
    font-size: 1rem;
    font-weight: 600;
}

/* ===== Weather Modal ===== */
.modal-weather {
    max-width: 420px;
    width: 100%;
}

.weather-modal-content {
    padding: 0;
}

.weather-loading,
.weather-error {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Current Weather */
.weather-current {
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.weather-current-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.weather-current-icon {
    font-size: 3.5rem;
    line-height: 1;
}

.weather-current-info {
    display: flex;
    flex-direction: column;
}

.weather-current-temp {
    font-size: 3rem;
    font-weight: 300;
    color: var(--text-primary);
    line-height: 1;
}

.weather-current-condition {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.weather-current-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.weather-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.5rem;
    background: var(--shadow);
    border-radius: 8px;
}

.weather-detail-icon {
    font-size: 1rem;
    opacity: 0.8;
}

.weather-detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.weather-detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.weather-sun-moon {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.weather-sun,
.weather-moon {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sun-icon,
.moon-icon {
    font-size: 1.1rem;
}

.sun-time,
.moon-phase {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Weather Sections */
.weather-section {
    margin-bottom: 1rem;
}

.weather-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* Hourly Forecast */
.weather-hourly {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-tertiary) transparent;
}

.weather-hourly::-webkit-scrollbar {
    height: 4px;
}

.weather-hourly::-webkit-scrollbar-track {
    background: transparent;
}

.weather-hourly::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 2px;
}

.weather-hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border-radius: 10px;
    min-width: 52px;
    flex-shrink: 0;
}

.hourly-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.hourly-icon {
    font-size: 1.25rem;
}

.hourly-temp {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hourly-pop {
    font-size: 0.65rem;
    color: var(--info);
}

/* Daily Forecast */
.weather-daily {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.weather-daily-item {
    display: grid;
    grid-template-columns: 50px 36px 50px 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border-radius: 8px;
}

.daily-day {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.daily-icon {
    font-size: 1.25rem;
    text-align: center;
}

.daily-pop {
    font-size: 0.75rem;
    color: var(--info);
    min-width: 50px;
}

.daily-temps {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.daily-high {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 32px;
    text-align: right;
}

.daily-low {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

