* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.05);
}

.auth-links {
    margin-top: 24px;
    text-align: center;
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

.divider {
    margin: 24px 0;
    text-align: center;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.divider span {
    background: var(--surface);
    padding: 0 16px;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Main App Layout */
.app-container {
    display: none;
    min-height: 100vh;
}

.header {
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.user-menu {
    position: relative;
}

.user-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.user-btn:hover {
    background: var(--background);
}

.dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    margin-top: 8px;
    display: none;
}

.dropdown.active {
    display: block;
}

.dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.dropdown-item:hover {
    background: var(--background);
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

.page-title {
    font-size: 24px;
    margin-bottom: 24px;
    color: var(--text-primary);
}

/* Device List */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.device-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.device-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 24px;
}

.device-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.device-info {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 12px;
}

.status-online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Device Detail Page */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 24px;
    transition: all 0.2s;
}

.back-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.device-detail-header {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.device-detail-title {
    font-size: 24px;
    margin-bottom: 8px;
}

.device-detail-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-small {
    padding: 10px 20px;
    font-size: 14px;
    width: auto;
}

.fixtures-area iframe {
    width: 100%;
    height: 100%;
    min-height: 350px;
    border: 0;
    display: block;
}

.fixtures-area {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    min-height: fit-content;
    box-shadow: var(--shadow);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

/* User Management */
.user-list {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.user-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item:last-child {
    border-bottom: none;
}

.user-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.user-info p {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--background);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary);
    color: white;
}

/* Wall Switch Configuration */
.switch-config {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.config-section {
    margin-bottom: 24px;
}

.config-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.switch-item {
    background: var(--background);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.switch-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.switch-name {
    font-weight: 600;
}

.toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle.active {
    background: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle.active::after {
    transform: translateX(24px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .auth-card {
        padding: 32px 24px;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        padding: 0 16px;
    }

    .main-content {
        padding: 20px 16px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-small {
        width: 100%;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 16px;
}

.mt-4 {
    margin-top: 16px;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Success/Error Messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.message-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.message-warning {
    background: rgba(222, 215, 78, 0.1);
    color: var(--warning);
    border: 1px solid var(--warning);
}
