/* Estilos para la aplicación Nuki Door Controller */

* {
    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;
    color: #333;
    overflow-x: hidden;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
}

.header h1 {
    font-size: 1.8em;
    margin-bottom: 10px;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9em;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4757;
    transition: background-color 0.3s ease;
}

.status-dot.connected {
    background: #2ed573;
}

.status-dot.connecting {
    background: #ffa502;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main content */
.main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Door status */
.door-status {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.door-icon {
    font-size: 3em;
    margin-bottom: 10px;
    transition: transform 0.3s ease;
}

.door-icon.opening {
    animation: shake 0.5s infinite;
}

.door-icon.closing {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.door-status h2 {
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 1.3em;
}

.door-status p {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.control-btn {
    flex: 1;
    padding: 20px;
    border: none;
    border-radius: 15px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.open-btn {
    background: linear-gradient(45deg, #2ed573, #17a2b8);
    color: white;
}

.close-btn {
    background: linear-gradient(45deg, #ff4757, #ff6b7a);
    color: white;
}

.control-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.control-btn:not(:disabled):active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.5em;
}

.btn-text {
    font-size: 0.9em;
}

/* Connection panel */
.connection-panel {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.connection-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.connect-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 auto 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.connect-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.help-text {
    color: #7f8c8d;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Info panel */
.info-panel {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.info-panel h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #ecf0f1;
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: #2c3e50;
}

.info-value {
    color: #7f8c8d;
    font-family: monospace;
}

/* History */
.history {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.history h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #ecf0f1;
}

.history-item:last-child {
    border-bottom: none;
}

.history-action {
    font-weight: 600;
    color: #2c3e50;
}

.history-time {
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Footer */
.footer {
    display: flex;
    background: white;
    border-top: 1px solid #ecf0f1;
    padding: 15px;
    gap: 10px;
}

.footer-btn {
    flex: 1;
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 12px;
    border-radius: 10px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-btn:hover {
    background: #667eea;
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
}

/* Modal de autenticación */
.auth-modal-content {
    max-width: 350px;
    width: 90%;
}

.auth-form {
    text-align: center;
}

.pin-input-container {
    margin-bottom: 20px;
    position: relative;
}

.pin-input-container input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pin-display {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    letter-spacing: 0.5em;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.pin-display.active {
    border-color: #667eea;
    background: #f0f2ff;
}

.pin-display.error {
    border-color: #ff4757;
    background: #fff5f5;
    color: #ff4757;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.pin-key {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    font-size: 1.2em;
    font-weight: bold;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-key:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: scale(1.05);
}

.pin-key:active {
    transform: scale(0.95);
    background: #667eea;
    color: white;
}

.clear-key {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.clear-key:hover {
    background: #ffeaa7;
    border-color: #f39c12;
}

.enter-key {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.enter-key:hover {
    background: #c3e6cb;
    border-color: #28a745;
}

.enter-key:disabled {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.auth-status {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.auth-status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #ecf0f1;
}

.modal-header h3 {
    color: #2c3e50;
    font-size: 1.3em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.modal-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.setting-group input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.setting-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.setting-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #667eea;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #ecf0f1;
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-primary:hover {
    background: #5a6fd8;
}

.btn-secondary:hover {
    background: #d5dbdb;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .control-btn {
        padding: 15px;
    }
    
    .footer {
        flex-direction: column;
    }
}

/* Animaciones de entrada */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.door-status, .controls, .connection-panel, .info-panel, .history {
    animation: fadeInUp 0.6s ease-out;
}

/* Estados especiales */
.door-status.opening {
    background: linear-gradient(45deg, #2ed573, #17a2b8);
    color: white;
}

.door-status.closing {
    background: linear-gradient(45deg, #ff4757, #ff6b7a);
    color: white;
}

.door-status.error {
    background: linear-gradient(45deg, #ff4757, #ff6b7a);
    color: white;
}
