* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #4CAF50;
    box-shadow: 0 0 10px #4CAF50;
}

.status-dot.disconnected {
    background: #f44336;
    box-shadow: 0 0 10px #f44336;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

main {
    padding: 20px;
}

.config-section,
.data-section,
.publish-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
}

h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2196F3;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
    color: #555;
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #2196F3;
}

.input-group input:disabled {
    background: #e0e0e0;
    cursor: not-allowed;
}

button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.btn-primary.connected {
    background: #f44336;
}

.btn-primary.connected:hover {
    background: #d32f2f;
}

.btn-secondary {
    background: #4CAF50;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-install {
    background: #FF9800;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-install:hover {
    background: #F57C00;
}

.btn-switch {
    background: #9C27B0;
    color: white;
    margin-top: 15px;
}

.btn-switch:hover:not(:disabled) {
    background: #7B1FA2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
}

.btn-switch:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.value-display {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #2196F3;
}

.value {
    font-size: 32px;
    font-weight: 700;
    color: #2196F3;
    word-break: break-all;
}

.no-data {
    font-size: 18px;
    color: #999;
}

.timestamp {
    margin-top: 10px;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    text-align: center;
}

.pulse {
    animation: pulseEffect 0.5s;
}

@keyframes pulseEffect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

footer {
    padding: 20px;
    text-align: center;
    background: #f5f5f5;
}

.install-section {
    display: block;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        border-radius: 0;
    }

    header h1 {
        font-size: 20px;
    }

    .value {
        font-size: 28px;
    }

    main {
        padding: 15px;
    }
}

/* Mejoras para PWA */
@media (display-mode: standalone) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }
}

/* iOS Safe Area */
@supports (padding: max(0px)) {
    body {
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Modal de Autenticación */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.auth-modal.active {
    display: flex;
}

.auth-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

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

.auth-content h2 {
    color: #2196F3;
    margin-bottom: 10px;
    text-align: center;
}

.auth-content p {
    text-align: center;
    color: #666;
    margin-bottom: 25px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #2196F3;
}

.auth-error {
    color: #f44336;
    font-size: 14px;
    margin-bottom: 15px;
    text-align: center;
    min-height: 20px;
}

.btn-auth {
    width: 100%;
    padding: 14px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-auth:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}
