/* Smart Home App Custom Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #0062ff 0%, #00d2ff 100%);
    --bg-gradient: linear-gradient(180deg, #f0f6ff 0%, #f9fbfe 100%);
    --primary: #0062ff;
    --primary-light: rgba(0, 98, 255, 0.1);
    --secondary: #00d2ff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --bg-card: #ffffff;
    --bg-app: #f4f8fc;
    --border-color: #e2e8f0;
    --shadow-soft: 0 10px 25px -5px rgba(0, 98, 255, 0.05), 0 8px 10px -6px rgba(0, 98, 255, 0.05);
    --shadow-md: 0 20px 25px -5px rgba(0, 98, 255, 0.1), 0 10px 10px -5px rgba(0, 98, 255, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--text-dark);
    min-height: 100vh;
}

/* Responsive container */
.app-container {
    width: 100%;
    min-height: 100vh;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 auto;
}

/* Header */
.app-header {
    background: var(--primary-gradient);
    color: #ffffff;
    padding: calc(24px + env(safe-area-inset-top)) 20px 40px 20px;
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
    position: relative;
    box-shadow: var(--shadow-md);
}

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

.profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.header-title {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.9;
}

.header-subtitle {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.weather-widget {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.weather-temp {
    font-size: 18px;
    font-weight: 600;
}

/* Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(90px + env(safe-area-inset-bottom)); /* offset for tab bar */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.app-content::-webkit-scrollbar {
    display: none;
}

/* Main Cards / Summary */
.summary-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 16px 20px;
    margin-top: -30px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-info {
    display: flex;
    flex-direction: column;
}

.summary-count {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.summary-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Room filters */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin-bottom: 20px;
    padding-bottom: 5px;
}

.room-scroll::-webkit-scrollbar {
    display: none;
}

.room-pill {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.room-pill.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 98, 255, 0.2);
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.device-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 18px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 155px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.device-card.active {
    background: linear-gradient(135deg, #ffffff 0%, #edf4ff 100%);
    border-color: rgba(0, 98, 255, 0.2);
}

.device-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.device-card.active .device-icon-wrapper {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 98, 255, 0.2);
}

.device-info {
    margin-top: 12px;
}

.device-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-room {
    font-size: 12px;
    color: var(--text-muted);
}

.device-status-badge {
    position: absolute;
    top: 18px;
    right: 18px;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
}

.badge-mock {
    background: #f1f5f9;
    color: #64748b;
}

.badge-tuya {
    background: #fff7ed;
    color: #ea580c;
}

/* Beautiful Switch */
.switch-control {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
}

.ios-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background: var(--primary-gradient);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Bottom Tab Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(80px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: 0 4px 10px;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 12px;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
    color: var(--primary);
}

/* Form Styles for login/settings/devices */
.form-container {
    background: #ffffff;
    border-radius: 28px;
    padding: 24px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background-color: #f8fafc;
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 98, 255, 0.1);
}

.btn-primary {
    width: 100%;
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 98, 255, 0.2);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* Device Manager Item */
.manager-item {
    background: #ffffff;
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manager-details h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.manager-details p {
    font-size: 12px;
    color: var(--text-muted);
}

.manager-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger {
    background-color: #fef2f2;
    color: #ef4444;
}

.btn-edit {
    background-color: #eff6ff;
    color: #3b82f6;
}

/* Toast System */
.toast-container {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 14px;
    margin-bottom: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

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

/* Login styling */
.login-header {
    text-align: center;
    padding: 60px 20px 40px 20px;
    background: var(--primary-gradient);
    color: #ffffff;
    border-bottom-left-radius: 35px;
    border-bottom-right-radius: 35px;
    box-shadow: var(--shadow-md);
}

.login-logo {
    width: 72px;
    height: 72px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px auto;
    font-size: 32px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    box-shadow: inset 0 0 15px rgba(255,255,255,0.2);
}

.login-body {
    padding: 30px 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.alert-error {
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    color: #b91c1c;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Logs Style */
.log-item {
    background: #ffffff;
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.log-info {
    display: flex;
    flex-direction: column;
}

.log-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.log-status {
    font-weight: 600;
}

.status-on {
    color: #10b981;
}

.status-off {
    color: #ef4444;
}
